Create instance from string
#1
Posted 27 February 2012 - 04:55 AM
If I have a global string variable with value, say, "Default" I would like to be able to use it to create all default instances, say oDefaultWall, oDefaultFloor, oDefaultDoor, etc. Please explain how to do this? I understand that instance_create can only use object id.
Thanks.
#2
Posted 27 February 2012 - 05:02 AM
#3
Posted 27 February 2012 - 05:23 AM
Yes my idea is to make it easier for me in generating environment in real time, so if I want an environment of a default platform with birds then I would have a global string like "Default-Birds" then the game will just create it using string operations and such. It's a canabalt type game so the game would generate it off screen and giving it negative speed as it rushes to the player onscreen. By using global string variable I can tweak it in real time and giving the player better environments rather than just randomly creating it.
I can of course use arrays which keeps a list of objects. Just wondering if there is an easier way with using string.
Edited by greyzebra, 27 February 2012 - 05:25 AM.
#4
Posted 27 February 2012 - 06:02 AM
I tried searching execute_string in Gamemaker:HTML5 help and cannot find it. I guess it is not supported? My fault I should have informed before.
Yes my idea is to make it easier for me in generating environment in real time, so if I want an environment of a default platform with birds then I would have a global string like "Default-Birds" then the game will just create it using string operations and such. It's a canabalt type game so the game would generate it off screen and giving it negative speed as it rushes to the player onscreen. By using global string variable I can tweak it in real time and giving the player better environments rather than just randomly creating it.
I can of course use arrays which keeps a list of objects. Just wondering if there is an easier way with using string.
Don't use strings for it. Just use the object ids, which are global already. Then just use a switch statement in a script that will create your specified instances.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











