Game maker studio 2 global variables
So we want the mouse event to start at the top of the stack and stop at the first object that takes an action on it. Given a stack of overlapping objects, many of them having a mouse event triggered by the same mouse-button-event, how do you stop the event from propagating through the whole stack? asset index of an object = object index of its instance Var assetIndex = asset_get_index("object_name") //returns index of asset, or -1 for not found Var objectName = object_get_name(object_index) //returns the string name of the object Object_index: the object index of the object this is an instance of Image_angle: degrees of rotation counter clockwise (if object has a draw event, read more)
Image_xscale: change width of image 0.5 = half normal width -1 = normal width but flipped Image_alpha: control transparency, 0 to 1 with 1 being fully opaque.ĭirection: direction of motion in degrees. Image_index: the index of the current sprite animation frame. Set to 1 to cycle one image per game step.
Image_speed: the rate at which the sprite animation is run. Sprite_height: read only updates to display height when image_yscale is changed Sprite_width: read only updates to display width when image_xscale is changed 1 means there is no sprite, in which case the dimensions may be reported as zero and/or infinity. Sprite_index: id of sprite assigned to object. Self: the current instance - you do not need to say "self" in object actions, just use the self variables directly The rest of these are built-in instance variables. Each instance of the object will have its own value. You can create custom instance variables simply by setting a value to an undeclared variable name. If you name a sound file "music" and you also have an included file called "music.ogg", the sound file will be set to "undefined" and will not run.
#Game maker studio 2 global variables code#
Put all initialization code in this room's creation event to guarantee it is run before anything else. Start with an empty Initialization Room and make sure it is the first in the list so it is run first. You'd have to recreate the whole sprite to "move" it in the organization structure. GameMaker does not allow drag-n-drop to move sprites into or out of a folder. If there is no logical script to make the parent, create a well-named dummy script to provide a name for the group.Ĭreate a sprite folder per category, such as Buttons, Labels, Animations.Įdit: maybe not. Organize scripts into logical groups under parent scripts. Exception: event_inherited() stays in the object That way you don't have to remember what is in the object and what is in a script. Have all objects call scripts even for simple tasks. Thoughts on keeping code organized within GameMaker:ĭo not put event code into objects.