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

GML I do not understand how to write in GML this icon

nnn1czech

Member
Nice day,
I do not see how I can write the following icon from the GMS 1 code in GML (in GMS 2)?

It is an icon named create moving
(I found a code in GML, but do not know where I write: obj = instance_create(x,y,object))

In obj_control:
applies to self
object: obj_card
x: 0
y: 0
speed: 0
direction: direction
 
Last edited:

matharoo

manualman
GameMaker Dev.
It would be something like this if you wanted to create an object that would move at a speed of 5 towards direction 90...
Code:
obj_create = instance_create_layer(x, y, "Instances", object);
with (obj_create){
    speed = 5;
    direction = 90;
}
So basically, what you need to do is, store your created instance's id in a variable, and then use with() to apply movement to it. Hope this helps.
 

nnn1czech

Member
I'll explain the situation.
I want to show the card to a random position in the room. I also want to paint a tab at the position where it is obj_card_spawn (not to thoughtlessly scattered).

I have an object (obj_control) and in the event I want to create a rendering obj_card at a random position instead obj_card_spawn.

If I understood correctly the information found, I have to use codes: obj = instance_create(x,y,object); obj.speed; obj.direction, I do not know what to write on instead of obj and on instead of object.

Or should I use another code? Please, what should I write?

I tried different things. Because I have a mistake somewhere (probably in this or I do not know where), so the game does not move as expected.
 

matharoo

manualman
GameMaker Dev.
So you want to create the objects at a random position?

instance_create_layer(x, y, "Instances", object);

in x, add the x position to create the object at.
in y, the y position to create the object at.
At object, add your object's name.

If you want to randomize the x/y positions, use random() or random_range()
 

nnn1czech

Member
Thank you for the advice. Sadly this did not solve the problem with the game. I guess I'll have to do something else differently.
 
Top