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

GameMaker Instance_create_layer with image_xscale/image_yscale

B

Birbbbb

Guest
So if the monsters have 0 hp I want to make an object called oDEAD which shows its dead body basically.
But it doesn't scale the monster to the scale I want it to be.
Where do I put in image scaling stuff? I am very new so sorry if I seem like a total idiot. Also, this code is on the begin step of an object I called oENEMY.

if (hp<= 0)
{
instance_create_layer(x,y,layer,oDEAD);
instance_destroy();
}
 

TheSpydog

Member
You can store a reference to your newly created oDEAD object inside a temporary variable and modify it from there, like so:

Code:
var corpse = instance_create_layer(x, y, layer, oDEAD);
with (corpse)
{
    image_xscale = the_scale_you_want;
    image_yscale = the_scale_you_want;
}
instance_destroy();
 
B

Birbbbb

Guest
You can store a reference to your newly created oDEAD object inside a temporary variable and modify it from there, like so:

Code:
var corpse = instance_create_layer(x, y, layer, oDEAD);
with (corpse)
{
    image_xscale = the_scale_you_want;
    image_yscale = the_scale_you_want;
}
instance_destroy();
THANK YOU SO MUCH!!!! IT WORKED PERFECTLY!!
Also, I got to learn what var and corpse is from your comment!
 

TheSpydog

Member
Awesome, glad it worked! By the way, "corpse" isn't anything special; it's just a name I came up with for the variable because it was referring to a dead monster. You could name that variable almost anything you'd like ("dead_monster", "my_dead_body", etc.) and it would still work the same. There are a few rules for variable names, like you can't have spaces in the name (like "dead monster" wouldn't be allowed) but for the most part you could just call it whatever you like. :)

Best of luck with your game!
 
B

Birbbbb

Guest
Awesome, glad it worked! By the way, "corpse" isn't anything special; it's just a name I came up with for the variable because it was referring to a dead monster. You could name that variable almost anything you'd like ("dead_monster", "my_dead_body", etc.) and it would still work the same. There are a few rules for variable names, like you can't have spaces in the name (like "dead monster" wouldn't be allowed) but for the most part you could just call it whatever you like. :)

Best of luck with your game!
Oh ok. I thought it was a built in function in the game for making dead bodies disappear easier or something. I feel stupid now. LOL Guess I should use the yoyo docs more often before assuming that corpse is a built-in function.
Anyways, tysm!
 
Top