Code doesn't seem to work for jump

Code doesn't seem to work for jump

Postby fireside » Tue Aug 12, 2014 9:18 pm

I haven't downloaded the source, but when I try the jump code, it doesn't work.

I ended up doing this to get it to work:
if (Ax.keys.pressed(AxKey.SPACE)&& this.wasTouching(DOWN)) {
velocity.y = -360;
y -= 1;

I had to use wasTouching because isTouching returned false, and I had to raise the y one pixel or it wouldn't budge.
Posts: 3
Joined: Tue Aug 12, 2014 2:28 pm

Re: Code doesn't seem to work for jump

Postby Arkeus » Tue Aug 12, 2014 9:23 pm

Usually having to use wasTouching and collision problems are caused by doing things in a different than normal order.

You should typically do all your game logic BEFORE super.update() in anything where you override update. Then you should include all .collide or .overlap calls AFTER the super.update(). Super.update() is where the engine handles all the core logic, so things like "isTouching" flags get swapped over, and become "wasTouching".
User avatar
Site Admin
Posts: 363
Joined: Mon Mar 26, 2012 12:43 am

Return to Axelite Basic

Who is online

Users browsing this forum: No registered users and 1 guest