Okay, so I'm designing a game right now where you have to click on enemies in order to target them. For example, in obj_Enemy, I have a left pressed event which means that the obj_Enemy gets targeted. However, the way its written makes it so that all obj_Enemy's on the screen are targeted:
global.Marked_Enemy = obj_Enemy
If two enemies are on the screen than this errors out. I thought about having a object that acts as a controller for battle and that left pressing in a specific location targets enemies. How would I go about doing this in actual code form:
If left pressed's location = obj_Enemy.x, obj_Enemy.y then . . .
Is there a way to make it so that I can mark objects based on their coordinates? Such as:
Set x and y to wherever you left pressed. If an object is there, set Marked_Enemy to that CLICKED object.
Left Pressed Event Help
Started by notoriouslynx, May 26 2012 01:43 AM
4 replies to this topic
#1
Posted 26 May 2012 - 01:43 AM
#2
Posted 26 May 2012 - 01:54 AM
get their IDs when you click on them.
they are always different!(you can go to the room editor and move your mouse over an object and it will show the id some where)
they are always different!(you can go to the room editor and move your mouse over an object and it will show the id some where)
#3
Posted 26 May 2012 - 01:57 AM
try global.Marked_Enemy = id
#4
Posted 26 May 2012 - 03:04 AM
Thanks guys, the ID worked. Marking an obj_Enemy creates three instances of obj_Mark at three positions in between the player character and the enemy. Pressing enter is suppose to make it so that the first Mark (Blue Orb) turns into a different sprite indicating attacking (Red Orb). However, I can't think get the ID because the ID will be new each time and I can't get them in the room creator since they are created. I'm trying to make it so that if an obj_Mark is at a certain position, the object is changed to obj_Attack. Anyway to do this? I thought instance_change(instance_position) or something like it would work, but nope.
#5
Posted 26 May 2012 - 03:23 AM
When you use instance_create it returns the id of the object you created.
So for example:
blueorb = instance_create(x,y,obj_Mark);
Then later:
blueorb.sprite_index = IAMASPRITESNAME;
So for example:
blueorb = instance_create(x,y,obj_Mark);
Then later:
blueorb.sprite_index = IAMASPRITESNAME;
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











