• 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!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Draw event running before create event

N

Neil Roberts

Guest
Hi

I have looked around for a solution to this with no luck.

I have a variable declared in a create event which is then used in the draw event of the same object. However when I run my program it gives me the "variable not set before reading it " error. I have disabled (commented out" all the code in both events and added a show_message command and discovered that the draw event runs first followed by the create event, I even added a show_message to the creation code of the instance in the room editor this one runs last of all. I am pretty sure this should not happen but it definitely is.

Any suggestions? I even created a new object with just a create and draw, and with only show_message commands and it is the same.

Forgot to mention I am using GM V1.4.1757
 
Last edited by a moderator:
W

William Dubois

Guest
Try to create an object and in the create event type this code ''image_speed = 0.1;'' (without '') after in the same object add the event ''animation end'' and now add your draw event. Is it works now?
 

Yal

šŸ§ *penguin noises*
GMC Elder
Workaround if you don't want to update: set the object to invisible in the object editor. Set visible to true in the create event. (The Draw event isn't run at all when an object is non-visible)
 
Top