enemy shooting at player
#1
Posted 03 March 2012 - 08:12 PM
#2
Posted 03 March 2012 - 08:21 PM
If the player is on the left side of the ennemi, he's having a smaller X position.
So use that as condition (if playerX < EnnemyX)
And then you need to know if the ennemi is facing the player. Is your ennemi using a different sprite for going and right? Or maybe it's just the image_scale than changes when he changes direction?
- If it's a different sprite for going left than going right, use the sprite as the condition. if(sprite_index=SpriteForGoingLeft)
- If it's the image scale that decides where your ennemy is facing then use the xscale as your condition. if(image_xscale=-1)
So basically, in your ennemy and the corresponding event you need depending its behavior, you would have something along the lines of:
if(obj_player.x<obj_Ennemy.x)&&(image_xscale=-1)
then
{ shooting code }
Edited by RangerX, 03 March 2012 - 08:22 PM.
#3
Posted 03 March 2012 - 08:59 PM
how would i put this in the logic of the enemy object?Ok, it's just a question of finding the right condition for your shooting code to happen. Let's think this up together shall we?
If the player is on the left side of the ennemi, he's having a smaller X position.
So use that as condition (if playerX < EnnemyX)
And then you need to know if the ennemi is facing the player. Is your ennemi using a different sprite for going and right? Or maybe it's just the image_scale than changes when he changes direction?
- If it's a different sprite for going left than going right, use the sprite as the condition. if(sprite_index=SpriteForGoingLeft)
- If it's the image scale that decides where your ennemy is facing then use the xscale as your condition. if(image_xscale=-1)
So basically, in your ennemy and the corresponding event you need depending its behavior, you would have something along the lines of:
if(obj_player.x<obj_Ennemy.x)&&(image_xscale=-1)
then
{ shooting code }
#4
Posted 03 March 2012 - 09:04 PM
#5
Posted 03 March 2012 - 10:09 PM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











