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

Spawn item depending on score

D

discocar

Guest
So I have this code in an object at the end of the game, this depending on how many times you miss spawns a medal in the room. so once you have finished you move on and see a medal. But it says wrong number of Arguments. When trying to load it. I don't know why it would be the wrong number of arguments. Thanks


Code:
if global.miss >= 1
{
    instance_create(o_gold);
}

if global.miss >= 6
{
    instance_create(o_silver);
}

if global.miss >= 10
{
    instance_create(o_bronze);
}
 
B

Bayesian

Guest
To use instance_create you have to specify the x and y position to spawn the new object. Like this:
Code:
instnace_create(100,200,oObject);
You can spawn things relative to the object ruing the code by doing:
Code:
instance_create(x+10,y-15,oObject);
This will spawn oObject 10 pixesl to the right and 15 pixels above the calling instance.
 

Perseus

Not Medusa
Forum Staff
Moderator
GameMaker shows that error message because your instance_create() calls do have the wrong number of arguments. The function requires three arguments in total, but you're providing it only one - which is the object index. The first two arguments are missing from each function call which are supposed to tell GameMaker the coordinates of the position at which an instance of the specified object is to be created. For full syntax and usage related information, please refer to the function's Manual entry.
 
  • Like
Reactions: HW.
Top