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

SOLVED: Scaling a created object

S

Shizuky

Guest
Hi , I wanted to create an object in room but I want it to be bigger and tried it with this code: instance_create_layer(320,320,"Text",oPlayer){
image_xscale=3
image_yscale=3
}


I thought it will scale the object to be bigger when created but the oPlayer is still same.
How could I make it bigger when created?
 

marasovec

Member
2 ways:
Like TheouAegis said: Using "with"
Code:
with(instance_create_layer(320, 320, "Text", oPlayer))
{
    image_xscale = 3;
    image_yscale = 3;
}
or using "."
Code:
var player_object = instance_create_layer(320, 320, "Text", oPlayer);
player_object.image_xscale = 3;
player_object.image_yscale = 3;
 
S

Shizuky

Guest
I tried both and it doesn't seems to be working.
I have it like this:
[ case quest.pat:
i++;
with(oPlayerIntro){
var inst = instance_place(x,y,inst_673366E4);
if (inst != noone and !instance_exists(obj_textbox)){
with(inst){
show_debug_message("INTROOO")
room_goto(room17);
instance_destroy(inst);
instance_destroy(oPlayerIntro);
var player_object = instance_create_layer(320, 320, "Text", oPlayer);
player_object.image_xscale = 3;
player_object.image_yscale = 3;
}
}
}]
 

NightFrost

Member
You have room_goto in the code, so it doesn't matter what the code does, because you'll be switching room afterwards and everything will be in the state presented by target room's editor view.

(Remember that a room change runs after currently running event ends, not in the middle of code.)
 
S

Shizuky

Guest
Is there a way to create a larger oPlayer and still go to a room? Or I need to rethink it completely to create it sooner?
 

NightFrost

Member
You need to message the next room somehow about player size. This could be accomplished through A) set a global variable that is checked in player create, B) have a persitent control object do player spawning as one of its duties (room start event), and before room change set a variable on it to modify player size, or C) make player persistent, but this may be troublesome as it then brings all of its current states to next room (including its position).
 
Top