CE State Machine Component
State machine component
Example
/// @desc Create
ce_init_components();
state_machine = ce_add_component(id, ce_state_machine_component);
state_idle = ce_state_create(state_machine);
state_move = ce_state_create(state_machine);
state_attack = ce_state_create(state_machine);
ce_set_state(state_idle);
/// @desc Step
switch (ce_get_state(state_machine))
{
case state_idle:
// ...
break;
case state_move:
// ...
break;
case state_attack:
// ...
break;
}
/// @desc User Event
switch (ce_get_event())
{
case CE_EV_STATE_CHANGED:
var _data = ce_get_event_data();
var _state_machine = data[0];
var _state_previous = data[1];
var _state_current = ce_get_state(_state_machine);
// ...
break;
}
Installation
Using Catalyst, the open-source package manager for GameMaker Studio 2:
catalyst require slagtand-org/ce-state-machine-component
Related
This library is a part of project CE. For more information, please visit the project's repository: https://github.com/slagtand-org/ce