Need help on how to go to the next frame with 2 objects colliding using code
Probably the var that is undefined.
fixed it
found a issue that it goes on 217 instead of 216 frame.
the proper way to use this.hits(that)
is to replace that
with the name of the clip you are testing collision for.
suppose you have a clip named player
and a clip named goal
. in the player
code, your update
script might look like:
if(this.hits(goal)) {
gotoNextFrame();
}
on that note, you are actually using gotoNextFrame()
incorrectly: there should be no input, because it is just going to the “next” frame. you may be thinking of gotoAndStop(putFrameNumberHere)
, where you can choose the frame number.
so if, in this hypothetical example, the win screen is on frame 10, you can do:
if(this.hits(goal)) {
gotoAndStop(10);
}
also if your wondering whats the full code i putted for the player. its this:
you do not have a clip called goal
. you have to name the clip to what you want.
i don’t know exactly what you are trying to make, so you might not want to call it goal
. it might be an enemy, a shop, etc. so name it whatever fits.
find the clip of whatever you are checking collision with the player for (maybe it’s a goal). you need to put the name of the clip in the text box. then, in the this.hits
thing, put in the same name.
Thank you! (the reason why it didnt work was because the name of the clip )
I tested it and once the player hits the goal it ends the game and says “error line 10”
is this thing called goal
?
of course (ten)
Good news! It finally worked