Hi all,
I am creating a platformer like mario or wonder boy, etc and wondering the best method of movement. I will be managing physics myself and not using Box2D.
Should the character (and the world) move (possibly at a different rates) or should the world just move. E.g. character jumps to right and world moves down and to the left.
Thanks
Comments
But ok if you ask me, then, most probably you would want your character to remain on in the same place on screen (like in the middle of the screen for example)
So there are two approaches.
You have a scene
background layer is added to the scene, and character is added to the background layer
This would be a box2d approach, because you already have the speed of moving object, and what you do is simply move the background in inverse speed in another direction, and your character would always stay in the middle of the screen
Example:
http://appcodingeasy.com/Gideros-Mobile/Gideros-Camera-Move
But since you will handle the physics on your own, you can:
have a scene
add background layer to the scene
add character to the scene
That way, you will be able to simply position your character in the middle of the screen, and it will always be there, and you can move background layer to any side independently. So you would only have to manipulate the world as you described.
I have done quite a lot of AS2/3 development as well as other languages but this will be my first larger scale game. Have made several small scale (viz Space Invaders, PacMan, etc) games before.
I have read in a couple of places that Box2D is not a good idea for platformer's due to it being too restrictive once the game starts to grow in size. What are your thoughts, from what I have read the jury is still out? I don't have a problem with doing my own physics but if Box2D is an option, then why reinvent the wheel?
Thanks for your input.
So maybe @phongtt could elaborate on how Cerberus puppy (http://giderosmobile.com/apps/cerberus-the-puppy) was created?
http://www.metanetsoftware.com/technique/tutorialA.html
(basically you'll end up reimplementing some of the algorithms in box2D)
You can try my game if you like. If it's the sort of thing you want to do I'd be happy to answer questions:
https://itunes.apple.com/us/app/nebula-retro/id730484292
https://play.google.com/store/apps/details?id=com.simpleinteractive.nebula&hl=en
Likes: phongtt
https://github.com/gideros/gideros
https://www.youtube.com/c/JohnBlackburn1975
The game I am making is more a multi-screen per scene sideways platformer like Mario Bros or Wonder Boy, etc. Old school gaming at its best . If I have any issues I will start another thread up and document the process for everyone to see.
Likes: ar2rsawseen
I did try not using Box2D to begin with but it just didn't look right. But if you follow the tutorial I linked above you can probably make it work.
I did have some issues with Box2D. It's important that the character can only jump when he is in contact with the ground not in mid air (except when he has rocket boost in my game). To do this I used box2D collision events BEGIN/END_CONTACT. But these do not distinguish between horizontal and vertical platform sides (they just tell you about fixtures, I was using rectangular fixtures). In the end I made this a feature so the character can jump off any platform (except for ice platforms). But in a classic platformer you will probably want your character to only be able to jump off a (near) horizontal surface. I'm not sure what the best way round this is? I guess you could use a body with multiple fixtures, for the top and sides of each platform. I've heard there is also a collision manifold but not sure what it is...
https://github.com/gideros/gideros
https://www.youtube.com/c/JohnBlackburn1975
https://github.com/gideros/gideros
https://www.youtube.com/c/JohnBlackburn1975
for example:
if manifold.normal.y < -0.9 then
and
if manifold.normal.y > -0.1 then
Another method I found is to create a "foot sensor" under the main body which fires only when in contact with the ground. Nice tutorial here:
http://www.iforce2d.net/b2dtut/jumpability
Probably there are pros and cons of these two methods...
https://github.com/gideros/gideros
https://www.youtube.com/c/JohnBlackburn1975
resloved problem, just need set name for fixtures after creat fixtures
example:
poly:setAsBox(bodyWidth*0.5,5,0,bodyHeight,0)
body.fixtureFootSensor = body:createFixture{
shape = poly,
density = 0.000001,
friction = 0,
restitution = 0,
isSensor = true
}
body.fixtureFootSensor.Name = "FootSensor"
--[[
i reading tutorial in box2d forums but dont know how to set user data to find different from fixtures]]
Dislikes: Yan