A
AtomicToilet
Guest
Howdy folks.
I've got it so the player can switch states when he presses 1, 2, 3 or 4 which changes the sprite colour and attack animation. That's all hunky dory. What I've now done is attach a particle system to the player object (so it leaves a trail behind them), which again works fine.
However, when the player changes states the particles remain one colour - I'd like to have it so it also changes colour (eg 1 = blue, 2 = green, etc). I thought adding a variable (RexColour) would work, with this added in each state script (eg RexColour = c_blue), so that once the states change the particle system then references the new variable details.
Except this variable is only referenced if I put it in the same Create Event as the particle system (otherwise it can't find the variable; it also still ignores the new variable reference when states/scripts are then changed). I also tried adding RexColour into the button press events but the variable's ignored then as well).
Basically, the game only seems to reference the RexColour variable in the player object Create Event.
What on earth am I doing wrong? Cheers for any help! If I should paste any other code, let me know
--------------------------------------------
Here's the object create code:
I've got it so the player can switch states when he presses 1, 2, 3 or 4 which changes the sprite colour and attack animation. That's all hunky dory. What I've now done is attach a particle system to the player object (so it leaves a trail behind them), which again works fine.
However, when the player changes states the particles remain one colour - I'd like to have it so it also changes colour (eg 1 = blue, 2 = green, etc). I thought adding a variable (RexColour) would work, with this added in each state script (eg RexColour = c_blue), so that once the states change the particle system then references the new variable details.
Except this variable is only referenced if I put it in the same Create Event as the particle system (otherwise it can't find the variable; it also still ignores the new variable reference when states/scripts are then changed). I also tried adding RexColour into the button press events but the variable's ignored then as well).
Basically, the game only seems to reference the RexColour variable in the player object Create Event.
What on earth am I doing wrong? Cheers for any help! If I should paste any other code, let me know
--------------------------------------------
Here's the object create code:
Code:
state = scr_rex_invincible; //Player (Rex) starts off invincible then presses 1 - 4 to change states
RexColour = c_white;
//particle system
partFairyDust_sys = part_system_create();
//Particle
partFairyDust = part_type_create();
part_type_size(partFairyDust, 1,2,0,0);
part_type_colour1(partFairyDust, RexColour); //RexColour should change depending on state
part_type_alpha2(partFairyDust, 1,0);
part_type_speed(partFairyDust, 0.8, 1, 0,0);
part_type_direction(partFairyDust, 0, 359,0,0);
part_type_blend(partFairyDust, 1);
part_type_life(partFairyDust, room_speed*2, room_speed*4);
//Particle emitter
partFairyDust_emit = part_emitter_create(partFairyDust_sys);
//These tie in to Step code that makes particles only form when player object is moving
old_x = 0;
old_y = 0;