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

Legacy GM Can't set direction on create

R

Rodimus

Guest
Hello!

I have an object, wich have a parent. At the create event i used the event_inerited() method, and inser the extra code. At the game, an object create instances of the previous object, and i try to set the direction - unseccesfulli.

What I done:

parent object:
Create Event:
...xy code..

child object:
Create Event:
event_Inherited();
xy code...

third object:

for (i = 0; i < ds_list_size(lista)i++)
{
obj = instance_create(x,y,ds_list_find_value(lista,0));
object.direction = 180; <<<<< THATS PART NOT WORKING. DOESN'T MATTER WHAT I DO
}

How can I set the direction?

Thanks for any help!
 
R

Rodimus

Guest
I mistype here, but the problem was that I want to work with the new direction immediatelly in the create event. I now set up an alarm in child object, and check direction there;
 

Tthecreator

Your Creator!
Ow, I understand your issue.
Yea the problem is that whenever you create your object using any of the instance_create_... functions, the create event is immediately launched.
Unfortunately, there is no way to solve this.
However, as a tip: the alarms will run a step later as you creation code.
Thus another option for you is to use a specific creation script, or make use of the user events to hold instance specific data bound to that instance.
Like this:
Code:
obj = instance_create(x,y,ds_list_find_value(lista,0));
obj.direction = 180;
with(obj){scr_creationcode();}
or:
Code:
obj = instance_create(x,y,ds_list_find_value(lista,0));
obj.direction = 180;
with(obj){event_user(4);}
 
W

Wraithious

Guest
Change the instance_create part of your code to:
Code:
with(instance_create(x,y,ds_list_find_value(lista,0)))
{
Direction=180;
}
 
R

Rodimus

Guest
This was my second idea, but the for loop around it not working, because the "i" is defined in the third object, and the child don't know trhe value of the "i".
 
Top