Z
zakblue
Guest
Hi Guys,
I'm farly new to GM2 and i'm making an RPG with a basic levelling system.
I have followed a youtube guide to have my character level up and all i would like is to have 3 seconds
of text popping up everytime my character levels up. I have had various struggles with this trying to get it to work without it affecting all the rest of the text on the screen, and then not just be persistent after showing.
The biggest difficulty i have is being able to trigger the popup, as if I add a key press event to 'trigger' the level up, I can cause the text popup.
I am controlling the levelling and stats in my player object.
I have tried creating a separate object for the popup text but i get much the same results as leaving it in the player object. 'ding' being the variable i would like as the trigger for the levelup text.
I will paste the code that i'm using (unnecessary extra fat like movment controls trimmed)
Create:
event_inherited(); //from enemy object parent I have setup
hp = 3;
spd = 2;
hspd = 0;
vspd = 0;
xaxis = 0;
yaxis = 0;
len = 0;
dir = 0;
image_speed = 0;
scr_get_input();
state = scr_move_state;
face = 0;
ding = false;
weapon_sprite = noone;
// Level up text
alarm[1] =room_speed * 3;
text_alpha = 1;
Step:
// Move the player in the step event
depth = -y;
script_execute(state);
sprite_index = sprite[face, movement];
// Check for death
if (obj_player_stats.hp <= 0) {
instance_destroy();
game_restart();
}
//Levelup
if (text_alpha > 0)
text_alpha -= 0.01;
Alarm 1:
ding=false;
Collision with experience object (that spawns after enemy killed) :
with (other) {
instance_destroy();
}
// Level up code
with (obj_player_stats) {
expr += 1;
if (expr >= maxexpr) {
level += 1;
expr = expr-maxexpr;
maxexpr *= 2;
hp += 2;
maxhp += 2;
stamina += 2;
maxstamina += 2;
attack += 1;
ding = true; // I thought I could use this variable changing to true to trigger the levelup txt
audio_play_sound(snd_levelup,0,false);
}
}
//most of the above ^^ variables have been set separately in obj_player_stats
Draw:
//Draw Player Shadow
draw_sprite(spr_player_shadow, image_index, x, y,);
draw_self();
if (ding) {
draw_set_colour(c_black);
draw_set_alpha(0.60);
draw_set_font(fnt_IG);
draw_set_color(c_white);
draw_text(x,y, "LevelUP");
draw_set_alpha(1);
}
KEY PRESS F1:
ding=true; //to test what happens here, and actually shows up 'LevelUP' in the correct place and disappearing after 3 seconds as required. This only works once though and then doesn't appear again on another press.
When my character actually levels up I don't get the 'LevelUP' on the screen, just the increase in stats.
I hope this makes sense, sorry I am fairly new to GM2 and stumped by this one.
Any help would be much appreciated!
I'm farly new to GM2 and i'm making an RPG with a basic levelling system.
I have followed a youtube guide to have my character level up and all i would like is to have 3 seconds
of text popping up everytime my character levels up. I have had various struggles with this trying to get it to work without it affecting all the rest of the text on the screen, and then not just be persistent after showing.
The biggest difficulty i have is being able to trigger the popup, as if I add a key press event to 'trigger' the level up, I can cause the text popup.
I am controlling the levelling and stats in my player object.
I have tried creating a separate object for the popup text but i get much the same results as leaving it in the player object. 'ding' being the variable i would like as the trigger for the levelup text.
I will paste the code that i'm using (unnecessary extra fat like movment controls trimmed)
Create:
event_inherited(); //from enemy object parent I have setup
hp = 3;
spd = 2;
hspd = 0;
vspd = 0;
xaxis = 0;
yaxis = 0;
len = 0;
dir = 0;
image_speed = 0;
scr_get_input();
state = scr_move_state;
face = 0;
ding = false;
weapon_sprite = noone;
// Level up text
alarm[1] =room_speed * 3;
text_alpha = 1;
Step:
// Move the player in the step event
depth = -y;
script_execute(state);
sprite_index = sprite[face, movement];
// Check for death
if (obj_player_stats.hp <= 0) {
instance_destroy();
game_restart();
}
//Levelup
if (text_alpha > 0)
text_alpha -= 0.01;
Alarm 1:
ding=false;
Collision with experience object (that spawns after enemy killed) :
with (other) {
instance_destroy();
}
// Level up code
with (obj_player_stats) {
expr += 1;
if (expr >= maxexpr) {
level += 1;
expr = expr-maxexpr;
maxexpr *= 2;
hp += 2;
maxhp += 2;
stamina += 2;
maxstamina += 2;
attack += 1;
ding = true; // I thought I could use this variable changing to true to trigger the levelup txt
audio_play_sound(snd_levelup,0,false);
}
}
//most of the above ^^ variables have been set separately in obj_player_stats
Draw:
//Draw Player Shadow
draw_sprite(spr_player_shadow, image_index, x, y,);
draw_self();
if (ding) {
draw_set_colour(c_black);
draw_set_alpha(0.60);
draw_set_font(fnt_IG);
draw_set_color(c_white);
draw_text(x,y, "LevelUP");
draw_set_alpha(1);
}
KEY PRESS F1:
ding=true; //to test what happens here, and actually shows up 'LevelUP' in the correct place and disappearing after 3 seconds as required. This only works once though and then doesn't appear again on another press.
When my character actually levels up I don't get the 'LevelUP' on the screen, just the increase in stats.
I hope this makes sense, sorry I am fairly new to GM2 and stumped by this one.
Any help would be much appreciated!