Datdiscordboi Posted June 21, 2017 Share Posted June 21, 2017 Hello there, I'm new to phaser and the first thing I had a minor quip with was the way animation calls were handled (they look messy and unorganized). I have experience coding in engines such as Vylocity ( http://vylocity.com ) where icon states are handled and managed by the direction the player/npc has chosen to go in. A player is set with an icon "state" which is a specific type of animation, each with its own directional states spit up (with the same number of states for each direction). This state references a file that is icons from a number to a number that those states are bound to. Here is an example of how the icon file looks, and i was wondering if there'd be an easy way to split up these images manually in code by specifying where each direction is, and then storing the file that they are referenced to as a string that would then be called. Then to set a character's animation, you would call this function that assigned the animation to it, grab the direction, and select the chosen section of the png file that contained that character's movement state. Maybe if I were to reorganize the icon file into something a bit easier for the engine to keep track of it wouldn't end up messy code-wise, especially when I needed to edit something. I could just split up each character direction into it's own file - the initial state would be for inactive movement while facing that direction, while the rest of the states would play while moving (e.g. while the key is being held) Can I get some idea on how I'd go about coding this. or if there already exists a library that simplifys animation calls. Link to comment Share on other sites More sharing options...
samme Posted June 22, 2017 Share Posted June 22, 2017 I don't think you need to split up the image file. I would just add animation names like walk:right, kick:right, sword:right, etc., then you can look them up quite easily. You can also use generateFrameNames to assign frame names in the same manner if that's helpful. Link to comment Share on other sites More sharing options...
Recommended Posts