case needs to be constant. what did i do wrong?

P

piksil_demon

Guest
so i was following this tutorial-
i tried my best to adapt it to the game im makeing, but for all the cases i put in my step event it said it needs to be a constant. what did i do wrong? heres my player info-
Information about object: obj_player
Sprite: spr_player_right
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code:

state = state.normal;

hp = 10;
atk = 10;
spd = 4;
ammo=1000;
randomize();


Step Event:
execute code:

switch (state)
{
case state.normal: scr_normal(); break;
case state.ranged: scr_ranged(); break;
case state.melee: scr_melee (); break;
}
 
A

anomalous

Guest
You did not declare your enum, and you used the wrong name in the case statement.

Before that, you need something like:
enum states
{
normal,
ranged,
melee
}

And in your case statement you need:
case states.normal

Notice state is the variable that holds the state.
states is the enum, where you put a "." after it for normal, ranged, or melee.
 
N

NPT

Guest
You don't remove your post.

You indicate it was solved and then let the post gracefully die. This way if other members can benifit from the solution.

If you have a post that really needs to be removed, then report it.
 
Top