• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Hitbox won't stay when I release attack key

E

Eugene Yap Yew Juen

Guest
Hi everyone, I'm new here, I would like to ask if anyone have this problem before and know how to fix it?
I'm trying to create a hitbox shows between the sprite animation, but hitbox only appear when I'm pressing attack key. I expect when I "pressed" the attack key once and the hitbox will stay until the animation is ended.
(Sorry for my bad English, please tell me if anyone don't get it)

//Attack animation
sprite_index = sSlash;

//Hitbox
if(image_index >= 1) && (image_index <= 3){

with(instance_create_layer(x,y,"Attack",oHitbox)) {

image_xscale = other.image_xscale;

with(instance_place(x,y,oEnemy)) {

hp -= 3;
vsp -= 3;
hsp = sign(x - other.x) * 4;
flash = 3;
image_xscale = sign(hsp);
}
}
}
 

Dupletor

Member
There is a sprite subimg limit in your animation, I suppose...
The current subimg for the sprite is called "image_index", and the total amount is "image_number".

You can make a Hitbox object wait until end of animation and then destroy itself.

Code:
if (animation.image_index == animation.image_number - 1)
instance_destroy();
https://docs.yoyogames.com/source/dadiospice/002_reference/objects and instances/instances/instance properties/image_number.html

https://docs.yoyogames.com/source/dadiospice/002_reference/objects and instances/instances/instance properties/image_index.html

https://docs.yoyogames.com/source/d...nces/instances/instance properties/index.html
 
Top