O
Okky Putra Perdana
Guest
I'm still learning with GMS 2, and recently i tried to create a charged mechanic. Basically, what i want to do is when i press "space" key, the player object will stop moving and begin charging. And then, when i release the "space" key, it will gain a boost movement for several time before going back to normal speed. Here is my code:
//Charge
var charge_time = 0;
if (keyboard_check(vk_space)) && charge_time < 1{
charge_time += 1;
mv_spd = 0;
if (charge_time > 5){
charge_time = 5;
}
}
x += hspd;
y += vspd;
if (keyboard_check_released(vk_space)){
mv_spd = 10;
charge_time -= 1;
if (charge_time < 0){
mv_spd = 4;
charge_time = 0;
}
}
The problem i face is when i release the "space" key, my player object didn't get the boost and still having the normal speed. Any suggestion?
Thank you very much.
//Charge
var charge_time = 0;
if (keyboard_check(vk_space)) && charge_time < 1{
charge_time += 1;
mv_spd = 0;
if (charge_time > 5){
charge_time = 5;
}
}
x += hspd;
y += vspd;
if (keyboard_check_released(vk_space)){
mv_spd = 10;
charge_time -= 1;
if (charge_time < 0){
mv_spd = 4;
charge_time = 0;
}
}
The problem i face is when i release the "space" key, my player object didn't get the boost and still having the normal speed. Any suggestion?
Thank you very much.