image - make a SpriteNode "jump" sprite kit iOS -


i programming small game. i've made character moving tilting phone. i'd character ( image spritenode ) jump, when touch screen. still want him move left , right when tilt phone while jumping. best way it? thinking making physicsworld , give him mass , activate gravity.

but how let him jump once when touch screen?

i'd happy answers.

thanks.

the question is: do need physics ?

it depends on want game

physic makes game more realistic, need?

  • does ground has slopes?
  • is there caves or several floors?
  • can pass through floors while jumping up? (doodle jump style)

your character have velocity associated, vector x , y speed. velocity applied each frame of game loop. simulate gravity, remove small amount of y velocity, begin fall down progressively, faster , faster. if want make character jump, apply relatively high amount of y velocity.


you may want subclass sknode add velocity property, can know , apply position in game loop, think apply existing horizontal movement mechanism velocity.

physic handles of velocity, forces, angular velocity, physics loop… you.
if want use physics, there's lot of tutorials online.

you can browse game development stack overflow community


replace skactions physics:

if(shouldmove) {     skaction *action = [skaction moveto:cgpointmake(destx, desty) duration:1];     [self.sanchez runaction:action]; } 

by

if(shouldmove) {     [self.sanchez.physicsbody applyforce:cgvectormake(data.acceleration.y * kplayerspeed, 0)]; } 

Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -