Capital J Productionz May 18th, 2016 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.
Capital J Productionz May 24th, 2016 It's working now, i didn't do anything different... I really believe that there is something wrong with my account cause i notice some weird things going on like when i save some changes don't actually get saved, i can't really log out., and i noticed that i can't add behaviors. I really think someone needs to look into my account, thanks again for all the help Gio and Foxcode. :)
Gio May 24th, 2016 I'm glad it's working now.
If you notice anything wrong, could you please let us know how to make it happen so we can fix it?
It should not be related to your account, as nothing is saved to your account specifically, it just gets saved locally in your browser's "cache" when you click save.
Your account is only used for things like posting comments here and some services such as the Android app builder require you to be logged in, but nothing to do with behaviors.
It would be very helpful if you could find a repeateable case where things don't work, it would really help us identify any problems.
echar July 13th, 2016 if (wade.getSceneObjects('isBlock',true).length<=0{
wade.app.createBlocks();
}
Correct is :
If (wade.getSceneObjects('isBlock',true).length===1{
wade.app.createBlocks();
}