Best practice; Physics, Accelerometer, Touch event and Jumping?

I was playing around a while ago with physics and accelerometer and wanted to make an object jump when “touch ended”. While doing this I tried two ways to accomplish this, first was to apply linearImpulse and second was to move object X pixels in the Y direction.

What way is the best to do this?

One thing I noticed is that I could make the object jump in mid air before it had landed on “ground”, which i didn’t really want it to be able to do. I guess now when I think about it I could have added some sort of collision detection when the object had landed so it could not jump before that collision had been detected?

Can anyone give me some feedback and/or some samples?

Sorry for not providing any code, I can’t write this from the top of my head but I can post some later when I have read a little more.

Thanks.
David [import]uid: 34126 topic_id: 9889 reply_id: 309889[/import]

Hey there!

Check out this link;
http://developer.anscamobile.com/content/game-edition-collision-detection

You are correct in that collision detection in the way to go; although there are other methods (such as if x < 100, or whatnot) it makes the most sense if platforms or the like are involved, or hills, or anything where the player would be above his starting X position but still on the ground.

There’s a useful sample in your Corona SDK Sample Code folder that may help as well :slight_smile:

Peach

[import]uid: 52491 topic_id: 9889 reply_id: 36083[/import]

thanks for the input, I have to read thru the docs again so I get a better understanding on this.

But then, since I plan on using Lime and make a tilemap game, would it be best to define a variable named ground where when ever the player collides he can jump again? Sorry for this one, it was just me thinking loudly…

Here’s another question, the iphone/ipod(s) have a max texture size 1024/2048 etc. If I make a 4 maps or any number for that fact, and want them to align next to each other or above.

Ok, what I ment was if i split the level in four 1024/2048 maps and place them so that map1 i at 0,0, map2 is at 1024,0 and map3 is at 0, 1024 and finally map4 at 1024, 1024. how would that work if I wanted the player to be able to run around between maps or if I use even more maps and make one huge world. How does that work with performance? is it going to be a loading period between the maps? or will I be able to run around as I please and the transitions will be seamless?
___________
|m1 | m2 |
| | |
|_____|____|
| m3 | m4 |
| | |
|_____|____|

feels like I messed up the post with explanation, but basically when player is on map1 and walks past x = 1024 - player.width/2 then map2 starts. Maybe I should have asked this in the lime thread…

anyways, how would such setup be laid out, how do I go about loading this?
sorry bout’ the messy post.
David

[import]uid: 34126 topic_id: 9889 reply_id: 36160[/import]

Yes, using a collision event to set onGround (or whatever you name your variable) to true would be best :slight_smile:

For your other question, take a look at this sample from the code exchange; http://developer.anscamobile.com/code/parallax-scrolling-module

It uses dragging however it sounds like the same basic idea; a map or world larger than the screen :slight_smile:

Peach [import]uid: 52491 topic_id: 9889 reply_id: 36210[/import]

Yes, using a collision event to set onGround (or whatever you name your variable) to true would be best :slight_smile:

It depends. What if there is a crate on the ground? This crate is not part of the ground, but yet you would expect to be able to jump again when you land on it. Also, you could hit the ground from below (in a platformer for example), in which case your boolean shouldn’t be set to true. [import]uid: 51516 topic_id: 9889 reply_id: 36236[/import]

Naturally there will be things that need working out, seth :slight_smile:

It’s very easy to add additional requirements for onGround = true, it needn’t be every time the ground is hit, it could be when the ground is hit and the character X > the other object (be it a crate, platform or the actual ground) X plus half the other object’s height.

I’m not trying to provide a complete, fool proof method for every kind of platformer game; only an answer as to whether or not using collision to tell when the player is on the ground so he can’t double/triple/etc jump would be acceptable.

Cheers!
Peach :slight_smile: [import]uid: 52491 topic_id: 9889 reply_id: 36563[/import]