1 decade ago
by eka
I'm working on a breakout clone to get to know impactjs. So far so good.
But I noticed that sometimes the ball after bouncing to the walls will go down in a 90 degrees, and that wasn't right.
Here is my collision map:
gist to ball entity
and here is a video of what's going on
video
Where do I start debugging?
1 decade ago
by eka
Wanted to make a note that it's not happening all the time, if I move the paddle and the ball gets another angle it doesn't happen.
1 decade ago
by drhayes
A couple of things:
You can make use of the JS statement
debugger
. Put it inside of an if, say...
updateAngle: function() {
this.angle = Math.atan2(this.vel.y, this.vel.x).toDeg();
if (this.vel.x === 0) {
debugger;
}
this.speed = Math.sqrt(Math.pow(this.vel.x, 2) + Math.pow(this.vel.y, 2));
},
You can also set
conditional breakpoints in the Chrome DevTools to see what happens when your angle is 270.
You
probably want your override of
handleMovementTrace
to call its parent first, before your code. Otherwise, you are setting velocity by angle/speed, then Impact comes along and resets it based on the collision map.
In the base
handleMovementTrace
, if your
vel.x
isn&
039;t greater than the #minBounceVelocity
(defaults to 40), then your
vel.x
will get set to 0.
I wouldn't bet hundreds of dollars that that's what's going on... but I have my suspicions.
1 decade ago
by eka
@drhayes:
Thanks for your tips. The problem was minBounceVelocity, cause vel.x was dropping below 40 and then the bounce stopped.
About the handleMovementTrace and calling parent first.
The idea was that parent update the velocities and then I can update the ball speed and update the velocities again... if I do parent first that gets screwed up and the ball doesn't bounce.
Thanks again.
PS: didn't know about the debugger code line... I was using dev tools breakpoints.
1 decade ago
by drhayes
Note to self: next time, bet hundreds of dollars.
Page 1 of 1
« first
« previous
next ›
last »