animation - How to animate player according to accelerometer in SpriteKit -


I am creating a jumper game like megazump I left the player can use the following code and tries to animate the rotation animation (not zRotation) have:

  // handle Akseloromitr L & R if (_x Acceleration & lt; - kAccelerationDeadZone & amp; (_currentPlayerHeading == Player Hedingap || _currentPlayerHeading == Player Hadingaprait)) {_currentPlayerHeading = PlayerHeadingUpLeft; [_player run action: _player animation header left]; } Else if (_x Acceleration & gt; Kesielarayrjdon & amp; amp; (_currentPlayerHeading == Player Hadingap || _currentPlayerHeading == Pleyrhadingapftft)) {_currentPlayerHeading = PlayerHeadingUpRight; [_player run action: _player animation head up wright]; }  

where each left and right animation is made from 3-4 frame problem is that it accelerometer changes will not easily react and I found that Megajmp like game animation It is extremely smooth as the reactions of each accelerometer change frame by frame (although the animation is also made of 3 -4 frame per side rotation)

What are the different frames of the animation Is there any easier way to respond to slight accelerometer changes to display them?

"itemprop =" text ">

After your last reply I have your own problem that the animation for the same side is running multiple times There is suspicion and may therefore be causing it to cause a mess in sight.

Keep in mind that accelerometer updates are very sensitive, for example you can get:

  0.6378 0.8041 0.6424  

On the other hand, depending on your KACLRAD adzone , this 3 animation may be due to running at almost the same time.

You can try two things Ngs:

1.- When an animation is running and an accelerometer handler in the player to ignore any other updates And create the player position. In this way the animation must end before starting another. Depending on how fast you are running those 3-4 frames, it may look good or not, for example when changing from left to right very fast and back to your player _playerAnimationHeadUpRight Animation is running, but can be skipped ...

2.- Do not run animation based on accelerometer values. Instead of just the player movement on the basis of these (kAccelerationDeadZone ) and applies to your update: Law Want to check your player's movement that brought him to the left or right and, Apart from the default, it is less than the default time to check it 60 times / second, in order to change the direction, several times a few times have to be changed.

Meaning:

  playerTimer + = deltaTime; If (playerTimer & gt; = kPlayerUpdateDelay) {if (player.position.x & gt; previousPosition.x) {// moving right} else if (player.position.x & LT; previousPosition.x) {// moving left } PreviousPosition X = player.Search; }  

If you post the code, where you create the animation, you can still help.

I know any updates.


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -