animation - Java/libgdx easy way to Equals enums? -
background info
since few days im working on multiplayer 2d rpg based on java/libgdx. today tried add animations player, worked idle animation. , heres questions how do more once? using png spritesheets different states idle, walking etc. used states in player class idle/walking right/left. in animation class there states too, same cant compare them because enums.
**main question **
is there easy way compare , set enums states out of
class player { public enum animationstates{ idle,right,left } animationstates currentstate; public animationstate getstatefromplayer(){ return currentstate; } } with
class animatedsprite{ public enum animationstates{ idle,right,left } animationstate currentstate = animationstate.idle; public void setstate (animationstate state){ currentstate = state; } } i tried few different things :
animatedsprite.setstate(player.getstate());
but didnt worked :/ solutions?
if have same name, in case do;
this how compare them:
player.currentstate.tostring().equals(animatedsprite.currentstate.tostring()) this how set 1 another:
player.setstate(player.animationstates.valueof(animatedsprite.currentstate.tostring())) here link might understand better:
Comments
Post a Comment