• 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!

Question on Draw Event and creating hitboxes(beginner)

J

Jyrish

Guest
I am at the point where im fleshing out the melee animation for my player and enemys. I have in ....
enemy draw event
draw_self();
if (attacking=true)
{
draw_sprite_ext(spr_attack,image_index,x,y,1.5,1.5,angle-60,image_blend,image_alpha)
}
//this works like i want to draw the attacking animation but i cant get a hit box in there?
all code to determine what animations of enemy, are in the step event
then i have a sprite for a slash attack(spr_attack) that has 5 frames and at position 3 is where i want the hit box to create and then disappear (only once)
Does the hit box need to be an object or can i just call the sprite?
but im not sure how to call the frames of spr_attack in the enemy step event cuz i think when i call image_index it called the enemys animations not the spr_attack being draw in draw event of obj_enemy.atkanimationforumnet.gif
 

Simon Gust

Member
The hitbox can either be an object of their own or just a sprite but then you'd need to have some form of collision inside the object that executes the attack.
 
J

Jyrish

Guest
still not answered... can i use the draw event to draw a separate animation and when that frame is triggered create object hitbox....does this make sense. i have a player object drawing self and animating, and also drawing the attack animation on mouseclick then checking for frame of attack animation to create a hitbox?
 
No, the draw_sprite literally only displays a sprite, it won't create a hitbox for that sprite. As simon said, you can either create an invisible object that you use for the hitbox of your attacking sprite (such as a small rectangle that you position with obj_player.x+whatever and obj_player.y+whatever that gets destroyed after your animation ends) or you can manually code in a 'hitbox', potentially using collision_rectangle (I think that's a function?) or something like that.
 

Xer0botXer0

Senpai
You can also create a new sprite from a surface which can be set to hidden and then set the image mask for a step or two.
 
Top