I am following part 3 of the "Breakout game tutorial" here and everything is going as plan but my sprite (a .png picture) does not hit the side of the walls. I am not getting any errors or anything, i am stuck at this point of the video here. Here is my code for the "ball player."
// My OnAddToScene Code
var velosity = {x:Math.random() < 0.5 ? this.speed: - this.speed,
y:Math.random() < 0.5 ? this.speed: - this.speed};
this.setVelocity(velosity);
// My OnUpdate Code
var collision = false;
var pos = this.getPosition();
var size = this.getSprite().getSize();
var halfWidth = wade.getScreenWidth()/2;
var halfHeight = wade.getScreenHeight()/2;
if(pos.x-size.x < -halfWidth || pos.x +size.y > halfWidth)
{
this.setVelocity({x:this.getVelocity().x*-1, y:this.getVelocity().y});
}
All help will be greatly appreciated.