Type : Struct
Anonymous state structs are structs containing the events for a state.
Note: You do not need to define all events used by other states when passing a state struct into .add(). It is enough to use the ones that are needed.
Example:
fsm.add("hit", { enter: function() { sprite_index = sSnakeHit; image_index = 0; hspd = spd*hitDir; }, step: function() { if (hspd != 0) hspd = approach(hspd, 0, hitAcc); else fsm.change("walk"); if (place_meeting(x+hspd, y, oWall)) flip(); move_and_collide(); }, draw: function() { var _ww = 6, _hh = 24, _height = 2; draw_healthbar(x-_ww, y-_hh, x+_ww, y-_hh+_height, (hp/hpMax)*100, c_black, c_red, c_green, 0, true, true); draw_self(); } });
This adds a "hit" state to state.
state
There was an error while loading. Please reload this page.