Paranoid1890 Posted July 21, 2016 Share Posted July 21, 2016 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 comment Share on other sites More sharing options...
TickleMeElmo Posted July 21, 2016 Share Posted July 21, 2016 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. bdekk and Paranoid1890 2 Link to comment Share on other sites More sharing options...
Paranoid1890 Posted July 26, 2016 Author Share Posted July 26, 2016 @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 comment Share on other sites More sharing options...
Recommended Posts