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?
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: On the other hand, depending on your 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 2.- Do not run animation based on accelerometer values. Instead of just the player movement on the basis of these (kAccelerationDeadZone Meaning: If you post the code, where you create the animation, you can still help. I know any updates.
0.6378 0.8041 0.6424
KACLRAD adzone
, this 3 animation may be due to running at almost the same time. _playerAnimationHeadUpRight
Animation is running, but can be skipped ...
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; }
Comments
Post a Comment