• 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 Created Instance not scaling

K00lman

Member
I am making a clicker and I was coding the upgrade buttons. I have it so that when the button is created, it runs:
Code:
x = room_width;
y = 63;

image_yscale = obj_store.image_yscale/2;
image_xscale = image_yscale;

while place_meeting(x, y, obj_upgrade){
    y += sprite_height;
}
and then in a controller object, I create it with:
Code:
upgrade_1 = instance_create_layer(0, 0, "Upgrades", obj_upgrade);
but each time it does not scale the sprite and it's super tiny. I tried to remove the variable with the instance ID, change the order of some of the code chunks, but no matter what it does not scale, though it runs the creation code as it shows up in the right location.
When placed manualy in room, it all scales and works properly.
 
Last edited:

TheouAegis

Member
If you change
image_yscale = obj_store.image_yscale/2
to something like
image_yscale = 5
does it work?

Is obj_store in the room? Is obj_store active? Have you verified obj_store's image_yscale is what you expect it to be?

Did you accidentally set the code action to target another object?

Do you have code in the Draw Event that is overriding the default drawing?
 

K00lman

Member
If you change
image_yscale = obj_store.image_yscale/2
to something like
image_yscale = 5
does it work?

Is obj_store in the room? Is obj_store active? Have you verified obj_store's image_yscale is what you expect it to be?

Did you accidentally set the code action to target another object?

Do you have code in the Draw Event that is overriding the default drawing?
Changing it to 5 worked.
obj_store is in the room and is scaling properly. I don't think there is any code that references another object outside of the code reference the other objects scale.
I don't know what you mean with the Draw event.
What is the value of obj_store.image_yscale, and how many obj_store instances are there?
There is only one obj_store, and it sets its scale with this code:
Code:
x = room_width;
y = 0;

image_yscale = room_height/sprite_height;
image_xscale = image_yscale;
 

Nidoking

Member
Okay, and what IS that value? Look at the obj_store.image_yscale in the debugger (or show_debug_message) and see what the value is.
 

Nidoking

Member
Is the sprite that's drawn not half the size of the sprite resource, in both directions? What are the dimensions of the sprite resource, and what are the dimensions drawn on screen? (It may help to go back into the debugger and look at sprite_width and sprite_height or the bbox_ variables.)
 

K00lman

Member
Is the sprite that's drawn not half the size of the sprite resource, in both directions? What are the dimensions of the sprite resource, and what are the dimensions drawn on screen? (It may help to go back into the debugger and look at sprite_width and sprite_height or the bbox_ variables.)
I'm sorry the image scale for the obj_store is ~4.21875. What I gave you before was the scale for the upgrade button.
 

K00lman

Member
After using the debugger to step through the code, it seems that when creating the instance from the controller object it runs its create code before the obj_store does, and therefore the stores scale is still 1. Any way to fix this?
 

SoapSud39

Member
After using the debugger to step through the code, it seems that when creating the instance from the controller object it runs its create code before the obj_store does, and therefore the stores scale is still 1. Any way to fix this?
There's a section in the room editor called Instance Creation Order (or something like that), where you can drag around your room instances, and the ones at the top get created first. Alternatively, if your objects are created in code, putting the instance create functions in the same object will make it really easy to order. Alternatively (again), in your objects category of your assets tree, the objects higher up on the list run their code first every step.
This is true for 2.2, and I haven't upgraded yet but I think there's a similar section in 2.3 that lets you choose your object order.
 

K00lman

Member
There's a section in the room editor called Instance Creation Order (or something like that), where you can drag around your room instances, and the ones at the top get created first. Alternatively, if your objects are created in code, putting the instance create functions in the same object will make it really easy to order. Alternatively (again), in your objects category of your assets tree, the objects higher up on the list run their code first every step.
This is true for 2.2, and I haven't upgraded yet but I think there's a similar section in 2.3 that lets you choose your object order.
When I move the obj_store to the top of the list the obj_upgrade does not show.
 

SoapSud39

Member
What do you mean by 'does not show'?

If you mean that you put obj_store in the top layer, then that's not the list I meant.
gms2 instance creation order.jpg
At least in 2.2, under Room Settings, if you press 'Instance Creation Order' the bottom part will show up. I'm not sure how it is in 2.3, but if you have that it might be similar. This will specify creation order, but not draw order. Draw order is determined by depth or layer.
 

K00lman

Member
What do you mean by 'does not show'?

If you mean that you put obj_store in the top layer, then that's not the list I meant.
View attachment 34143
At least in 2.2, under Room Settings, if you press 'Instance Creation Order' the bottom part will show up. I'm not sure how it is in 2.3, but if you have that it might be similar. This will specify creation order, but not draw order. Draw order is determined by depth or layer.
I moved the obj_store to the top of the list in the photo. The obj_upgrade is being drawn behind the obj_store.
bugs.png
 
Top