0
\$\begingroup\$

Alright, I'm looking how to create an instance, and then run a chunk of code on the instance I just created, and not have that code run on any other duplicate instances.

Noob question, I know. Please help though?

\$\endgroup\$
1
\$\begingroup\$

There are many ways. For example:

with instance_create(posx, posy, obj_enemy)
{
    direction = choose(0, 90, 180, 270);
    speed = 4;
}

Or you may separate creation and code:

var obj = instance_create(posx, posy, obj_enemy);
...
with obj
{
    direction = choose(0, 90, 180, 270);
    speed = 4;
}
\$\endgroup\$
1
  • \$\begingroup\$ This answer is genius! +1 I never considered using this as a method. I always only set variables and just do obj.var = var2; :p \$\endgroup\$ – user64742 Oct 25 '16 at 5:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.