Creation code bug?
#1
Posted 21 February 2012 - 04:03 AM
I have a sprite I use to create slopes in my platformer game. I wanted to use the less sprites and objects possible so I decided to have only one set of objects and simply "mirror" the sprites by a local variable when I need that slope the other way. This works wonderfully in GM8 but when I port my game in GM HTML5, it doesn't work anymore. I currently can't find an explanation.
In the creation code of the instance of my slope object I have:
Cimage_xscale=-1;
In the create event of the object I have:
if(!variable_local_exists("Cimage_xscale"))
then
{
image_xscale=1;
}
Still, when I start the game, the sprite isn't flipped. In GM8 it is flipped. What gives? bug?
#2
Posted 21 February 2012 - 08:24 AM
To avoid the need for this, you can now "flip" creation code order. Inside the "Global Game Settings / HML5" there is a new "tick box" option to "Change Creation Event Order". Ticking this causes the object create event to run BEFORE the room creation code. This means there should never be any need for variables exists functions.
#3
Posted 21 February 2012 - 12:25 PM
However, I'm not using room creation code, I'm using creation code in the slope object. Ticking the "change creation event order" doesn't solve the problem.
Is there another way I can tell a specific instance of my slope object to flip its sprite? If not, it means there actually is a need for the variable exists functions. :/
#4
Posted 21 February 2012 - 02:20 PM
Just ticking "Change creation event order" is only part of the puzzle. You need to change the coding as well.However, I'm not using room creation code, I'm using creation code in the slope object. Ticking the "change creation event order" doesn't solve the problem.
Is there another way I can tell a specific instance of my slope object to flip its sprite? If not, it means there actually is a need for the variable exists functions.
Creation:
//Default: Flipped image_xscale = -1;
Instance Creation:
//Override the flip image_xscale = 1;
No additional variables are needed.
GameGeisha
PS: I assumed that the default course of action is to flip the sprite, and that the instance creation code is responsible for unflipping it. You seem to have a typo in your original code where this is apparently true. If the reverse is what you intended, switch the two pieces around.
#5
Posted 21 February 2012 - 03:34 PM
Russell
#6
Posted 21 February 2012 - 09:34 PM
obj_Spawner instance create code (id 10001):
m_NumSpawn = 30;
m_AlarmSpawn = room_speed * 60 * 5; //every 5 minutes
obj_Spanner instance create code (id 10002):
m_NumSpawn = 5;
m_AlarmSpawn = room_speed * 30; //every 30 seconds
obj_Spawner create code
alarm[0] = local_variable_get("m_AlarmSpawn"); //defaults to 0 if not set
m_NumSpawn = local_variable_get("m_NumSpawn");
or you can use the variable exists in the first post to set to a default other than 0
alarm0 code
repeat(m_NumSpawn) instance_create(x,y,obj_Zombie);
Now the question is:
Is this broken?
If so, is it possible to re-instate it?
If not in it's current form, I would very much like to see the ability for us to create properties
obj_Spawner create code
property m_AlarmSpawn type double default 0;
property m_NumSpawn type double default 0;
alarm[0] = m_AlarmSpawn; //defaults to 0 if not set
which can be detected and added in that Instance Property window for us to tweak the variables on an instance to instance basis like we used to.
#7
Posted 21 February 2012 - 11:15 PM
I will try that tonight.
This topic is solved on my part but I am curious about icuurd12b42's apparently manual way of handling local variables. Not sure I understand clearly what's written there though.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











