Jump to content

Jump from a moving obeject on another moving object

Recommended Posts

Hello. I'm working on a "jungle jump" phaser game and got stucked with it. The use case is very easy: there are some swinging ropes on the top of the screen (they are moving separately with a constant speed), and there is a "Monkey" which jump from one rope on other. When he fail the jump, falling down and waste a life. 

I found a way how can I generate and move the ropes. But I can't figure out how can move together the monkey and the rope and how can jump from one moving rope on other. 

Any code example would be helpful, or if have additional question feel free to ask.

I found a picture which very similar to my game.

p.s I have to say that I'm just now started with phaser. 


Link to post
Share on other sites

well I don't think this is something you should do as a starter though, but if your good at math you'll figure it out, it's practically just a math homework :). I really don't have the time to explain it all to you but I can bring the basic way(there's also many more ways to do this).

to detect collision you create line out of the rope and lines of the monkey bounding box, then you detect if ropes line intersects with any line of the monkey bounding box. then a thing you can do with phaser is practically set the monkey as a child of rope so it seems like it is swinging with it, on jump you can kind of do what ever you want to do, you can calculate velocity vectors from cords traveled since last frame or you can have some kind of constant speed etc.


Link to post
Share on other sites

@TickleMeElmo thanks for reply. It helped me and confirmed the idea what I has. This is my solution (I know it's not the best but maybe it will help for someone else): 

All the ropes I put in an array (as a single object), and the monkey is a separate object. By default I'm grouping the first rope with the monkey and they are swinging together. Now when I want to jump, somehow I have to take out the monkey from the group. The only solution for this what I found is to get the position of the monkey when the jump is clicked. Then I kill() the monkey object and make the jump animation. If overlap happened with other rope (for this detection I has to use the "overlap without physics" solution, because arcade overlap fired outside of collision. I don't know why), then I again set a variable with monkey-s current x,y coordinates, again reset the object and group with the next rope. 

The only problem with this solution that the canvas width should be huge...

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...