Frogger-Like Movement

Hi,

I’m currently making a frogger style game for my own learning. I have something very simple set up so far. I was wondering how most people would approach this game with corona. I have logs moving decently and was wondering how I could keep the frog to stay on the log. What I mean is how would I keep the frog moving at the same pace as the log when it’s collided with it. I’m using isSensor.

If code is needed, I will post.

Thanks [import]uid: 149983 topic_id: 26516 reply_id: 326516[/import]

One option here would be to use a Runtime listener once the frog collides with the sensor - first compare frog x to log x and then keep that the same until they press a movement key again.

Does that make sense?

Peach :slight_smile: [import]uid: 52491 topic_id: 26516 reply_id: 107563[/import]

Sorry for the late reply.

It makes sense but could I do it by using collisions using bodies?
That’s what I have so far.

Here’s the code I have so far.

http://cl.ly/3e253V242w1m0q1U353r

Thanks
– EDIT

oops. sorry. I understand what you’re saying now.
Do I just put in a event listener within a event listener if that makes sense to you?
How do I check for the button press after the collision detection of “began”?

Thanks [import]uid: 149983 topic_id: 26516 reply_id: 108089[/import]

You don’t *have* to use collision detection, though it would be easiest. You could also compare coordinates using a Runtime listener but yes, would be a fair bit more work.

I am not quite sure on your Q, “How do I check for the button press after the collision detection of “began”?”

Do you mean so you know when the frog moves off the log? If so you would use a flag, eg;
frogOnLog = false

Set it to true when the frog collides with the log then to false when the button is pressed *before* moving the frog again.

Peach :slight_smile: [import]uid: 52491 topic_id: 26516 reply_id: 108268[/import]