User Tools

Site Tools


en:guides:beginners:changing_direction

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
guides:beginners:changing_direction [2015/12/06 12:10 (9 years ago)] – external edit 127.0.0.1en:guides:beginners:changing_direction [2018/06/28 07:45 (6 years ago)] (current) – external edit 127.0.0.1
Line 22: Line 22:
 } }
 else { else {
-    orxObject_SetTargetAnim(hero, orxNULL);+    orxObject_SetTargetAnim(hero, "HeroIdle");
 } }
 </code> </code>
Line 28: Line 28:
 The orxObject_SetScale function is being used here instead of the usual orxObject_SetFlip. The latter does not flip child objects or body positions, but scale does. We will need this later when our hero has a child gun object. The orxObject_SetScale function is being used here instead of the usual orxObject_SetFlip. The latter does not flip child objects or body positions, but scale does. We will need this later when our hero has a child gun object.
  
-Notice that we need to restore the flip when the right key is pressed.+Compile and Run. We can run left and right and the flipping is correct. But... there is a huge gap when the hero switches directions.
  
-Finally, ensure the pivot for our hero'graphics are centered so that when we flip left and right, there won't be any issues with the physically body shifting incorrectly:+Therefore we need to ensure the pivot for our hero'graphic and animation set are both centered so that when we flip left and right, there won't be any issues with the physically body shifting incorrectly:
  
 <code=ini> <code=ini>
 [HeroGraphic] [HeroGraphic]
 Texture        = soldier_full.png Texture        = soldier_full.png
-TextureCorner  = (0,0,0)+TextureOrigin  = (0,0,0)
 TextureSize    = (32,32,0) TextureSize    = (32,32,0)
 Pivot          = center Pivot          = center
 +
 +[HeroAnimationSet]
 +Texture    = soldier_full.png
 +FrameSize  = (32, 32, 0)
 +HeroRun    = 6
 +HeroIdle   = 1
 +StartAnim  = HeroIdle
 +HeroIdle-> = HeroIdle # .HeroRun
 +HeroRun->  = HeroRun # HeroIdle
 +Pivot      = center
 </code> </code>
  
-Compile and run. We can run left and right. That should be working well, our hero can now run left and right, or stand idle either left or right.+ 
 +Compile and run. That should be working much better. Our hero can run left and right, or stand idle either left or right.
  
 ---- ----
  
-Next, [[guides:beginners:shooting_and_spawners|Part 13 - getting our hero to shoot]].+Next, [[en:guides:beginners:shooting_and_spawners|Part 13 - getting our hero to shoot]]. 
 + 
 +{{section>en:guides:beginners:toc&noheader&nofooter&noeditbutton}}
en/guides/beginners/changing_direction.1449432655.txt.gz · Last modified: 2017/05/30 00:50 (7 years ago) (external edit)