Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

How to walk & attack at the same time with 2 separate atlases?


Aerion
 Share

Recommended Posts

Hi folks. How do I get my character to walk and attack at the same time with 2 separate character atlas files?

For instance, when you're walking, you press a key & while holding the walking keys, you can swing your sword WHILE walking at the same time through 2 separate but similar animation atlases.

Thanks!

~M

Edited by Mythros
Link to comment
Share on other sites

  • Aerion changed the title to How to walk & attack at the same time with 2 separate atlases?

Combine your atlas to one, otherwise you'll have performance issues. If you want something easy though, you can switch out your texture atlas using `loadTexture`

sprite.loadTexture(key, frame, stopAnimation)

https://phaser.io/docs/2.6.2/Phaser.Sprite.html


That is, you can have the sprite, then when walking change the texture with loadTexture, and when attacking change it again with loadTexture. Again, I encourage you to combine these and just use multiple animations (attacking animation, walking animation)

However, note that it will always look like it's walking OR attacking, it can't be both - Think about it, your images sprite sheets are walking and attacking, no game engine will magically make it look like it's doing both. Unless you use a skeletal animation system like Spine, DragonBones, or Creature

Link to comment
Share on other sites

  • 2 weeks later...
On 11/9/2017 at 5:52 AM, Mythros said:

I just wanna walk and swing a sword. Link from Legend of Zelda series is a PERFECT idea of what I want to do here. As long as it can be done easily & free that's all I care about. An example would be great! <3

Thank you SO MUCH! <3

~M

The original Zelda doesn't walk and attack at the same time though. Can you link a gameplay video of the specific installment you mean?

Also, as I mentioned already, what you need to do is have a special/separate 'attacking while walking' animation. No engine can magically combine both, other than through clever tricks that would be harder for a beginner. For examlple, BitOfGold's idea might work for you, but now you are using two sprites to represent one while keeping them in sync and do all physics at the same time. Much easier and faster to just make the art

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...