• 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!

GML Reasons why Draw event is not being called?

L

lukbebalduke

Guest
Debugging a strange issue in my game I have noticed that the draw event is not being called. (that means, if a put a breakpoint in the very first line of the code it does not even show in the debug.)

The first thing I decided to do was to check if the instance was visible, and yes, it is! The instance is also activated.

After checking that I got stuck and right now I have no idea why the draw event is not being called. Does anyone have any insights into this problem?

Thanks
 
D

dugtrioramen

Guest
Debugging a strange issue in my game I have noticed that the draw event is not being called. (that means, if a put a breakpoint in the very first line of the code it does not even show in the debug.)

The first thing I decided to do was to check if the instance was visible, and yes, it is! The instance is also activated.

After checking that I got stuck and right now I have no idea why the draw event is not being called. Does anyone have any insights into this problem?

Thanks
Do you mean that the object is not drawing itself?
If so, in the draw event
draw_self()
If not that, I don't know what you mean
 
L

lukbebalduke

Guest
draw event is not being called.
That's what I mean.

draw_self() would definitely draw the object, but the event itself is not being called.
 

Rob

Member
Can you show your code?

Not seeing a sprite can be down to many things.

In GM2 I keep accidentally changing the origin point of sprites without noticing and then I have to figure out why they're out of place.

It could also be down to depth, no sprite, draw event with no draw_self(); and many other things.
 

TheouAegis

Member
Are other objects drawing themselves? You didn't turn off automatic drawing, did you?

Is the game actually still running? Are you sure you did not create A infinite Loop somewhere that is being processed before that instance can draw itself?

What tests have you done to verify the instance is not deactivated, that it is visible, and that it has not been destroyed? You can only verify that with debug code, so what debug codes have you used?
 
L

lukbebalduke

Guest
Can you show your code?

Not seeing a sprite can be down to many things.

In GM2 I keep accidentally changing the origin point of sprites without noticing and then I have to figure out why they're out of place.

It could also be down to depth, no sprite, draw event with no draw_self(); and many other things.
That's not the issue. The DRAW EVENT ITSELF is not being called.


Are other objects drawing themselves? You didn't turn off automatic drawing, did you?

Is the game actually still running? Are you sure you did not create A infinite Loop somewhere that is being processed before that instance can draw itself?

What tests have you done to verify the instance is not deactivated, that it is visible, and that it has not been destroyed? You can only verify that with debug code, so what debug codes have you used?
The issue happens in a very specific object.

You didn't turn off automatic drawing, did you?
I have no idea, is there any other way to disable automatic drawing other than setting visible to false?

The game still running, it is not stuck in a loop. And the object is activated and set to visible because I can check its variables in real time at the debug (not printing anything, just checking the value at the default debug window). The code I am using to verify that the draw event is not being called is just a simple show_debug_message.
 

Electros

Member
Does the affected object have any parents / children (in case something affecting / overriding in the inheritance chain is impacting it)?
 

JeffJ

Member
You say the issue is present only in that single specific object.

Make a new separate project with nothing but that object. That should narrow things down.

Then show us everything that object does - all its events. Beyond that, it's nearly impossible to tell with no context to the rest of your project. Could be any number of things.
 

TheouAegis

Member
Quick fix method: Delete the instance from the room then put it back in (if applicable), click the dustpan icon to clear the project cache, click Save.


Does deactivating stop even the debugger from reading data about an instance? Seems like an oversight if the game can still read variables from deactivated instances but not the debugger...
 
Just to be absolutely sure, put a show_message() in the draw event. I've had problems with breakpoints before, so it is worth double checking.

Also, put a show_message in a keypress event so you can check that the instance still exists and is active.
 

ZeDuval

Member
Just so you know that you're not going insane - i had the exact same issue yesterday. One single instance of a specific object, (normal) Draw event, HTML export in my case btw. Tried a few things, could not find any reason, nor a solution, went to bed instead. Gonna look at this next time working on that project and hopefully remember to report back.
 

samspade

Member
Things to try (sounds like you've tried a couple already):
  • Breakpoints in create, step, and draw events
  • show_debug_message in create, step, and draw events
  • delete the draw event and see if it draws normally
  • delete the draw code and try different draw code
  • change the sprite
  • if you're placing it manually in the room, place it through code
  • try drawing from another instance using with (e.g. copy and paste draw event into a with block in another object that does exist and is being drawn)
  • check for something that would accidentally exit or skip portions of code such as keywords like break, exit, continue, and so on.
  • put more instances of the object in the room and see if they have the same effect
  • copy the object and put that object in the room
  • copy the code to notepad, delete the object, then create a new one and copy the code back
  • close game maker and re-open it
  • check for creation code or something else that could be messing with the object
  • clear cache
  • test a different export if you have the licenses or yyc
 
L

lukbebalduke

Guest
Its been a long and I still have no idea what is happening.

>Breakpoints in create, step, and draw events
>Show_debug_message in create, step, and draw events


Done all sort of things related to that. Every event works fine, draw although is skipped.

>Delete the draw event and see if it draws normally
>Delete the draw code and try different draw code


Bug persists. Sometimes the draw is simply disabled.

>Change the sprite


Happens in different sprites also.

>if you're placing it manually in the room, place it through the code

I am placing it through code.

>try drawing from another instance using with (e.g. copy and paste draw event into a with the block in another object that does exist and is being drawn)

I tried even force calling the draw event with event_perform, still does not solve the problem.

>check for something that would accidentally exit or skip portions of code such as keywords like a break, exit, continue, and so on.

It would not be the case since the bug still happens with no drawing code.

>put more instances of the object in the room and see if they have the same effect


Different objects have the same bug.

>copy the object and put that object in the room


Done. Still does not solve the bug.

>copy the code to notepad, delete the object, then create a new one and copy the code back


Done a few times. The bug persists

>close game maker and re-open it


Done a few times. The bug persists

>check for creation code or something else that could be messing with the object

Nothing found. Objects that have no correlation with each other manifest the bug.

>clear cache
>test a different export if you have the licenses or yyc


Done a few times. The bug persists
I will also try to give more details since the bug got a lot worse lately.

SEE THE IMAGE: https://imgur.com/lOeGZ2s

This issue happens in different types of objects: characters, props, etc... .In the recent version of game maker 2.2, ALL THE OBJECTS are skipping their draw event.

Could it be something related to the camera projection?
I guess I should report as a bug? I've never seen something like that in game maker.
 
L

lukbebalduke

Guest
After some months, I just solved it.

It is an issue with the camera projection: and I just realized it because there was an inconsistent from the last version of game maker to the new one. A function that was just causing some flickering started to vanish the entire game.

Well, I tell you what I did and maybe someone can explain to me what happened haha! I changed this line of code:
Code:
var vmatrix = matrix_build_lookat( applyx, applyy, -50, applyx, applyy, 0, 0, 1, 0);   
camera_set_view_mat( CAMERA_0, vmatrix);

var pmatrix = matrix_build_projection_ortho( BASE_WIDTH*APPLY_ZOOM, BASE_HEIGHT*APPLY_ZOOM, 0.0, 32000.0);
camera_set_proj_mat( CAMERA_0, pmatrix);
To that one:

Code:
camera_set_view_pos(CAMERA_0, applyx - camw*0.5, applyy - camh*0.5);
    camera_set_view_size( CAMERA_0, camw, camh);
Anyways, thanks for everyone that was trying to help me with this problem :)
 

samspade

Member
After some months, I just solved it.

It is an issue with the camera projection: and I just realized it because there was an inconsistent from the last version of game maker to the new one. A function that was just causing some flickering started to vanish the entire game.

Well, I tell you what I did and maybe someone can explain to me what happened haha! I changed this line of code:
Code:
var vmatrix = matrix_build_lookat( applyx, applyy, -50, applyx, applyy, 0, 0, 1, 0);  
camera_set_view_mat( CAMERA_0, vmatrix);

var pmatrix = matrix_build_projection_ortho( BASE_WIDTH*APPLY_ZOOM, BASE_HEIGHT*APPLY_ZOOM, 0.0, 32000.0);
camera_set_proj_mat( CAMERA_0, pmatrix);
To that one:

Code:
camera_set_view_pos(CAMERA_0, applyx - camw*0.5, applyy - camh*0.5);
    camera_set_view_size( CAMERA_0, camw, camh);
Anyways, thanks for everyone that was trying to help me with this problem :)
Okay, I had a very similar problem myself today. There's no way for me to know if it is the exact thing you were experiencing, but here is what was happening and how I fixed it.

I had events which were not drawing. They were firing, just nothing was being drawn to the screen. I know they were firing through checking the debugger and by using show debug message. I also use a camera based on the matrix build functions here's my setup code:

Code:
var view_mat = matrix_build_lookat(xx, yy, -1, xx, yy, 0, 0, 1, 0);
var proj_mat = matrix_build_projection_ortho(camera_width, camera_height, -1000, 10000); //this line right here
camera_set_view_mat(CAMERA, view_mat);
camera_set_proj_mat(CAMERA, proj_mat);
The problem was the second line. The last two arguments, which haven't mattered in so long I forgot what they did, are the near and far clipping plane. Or to put it another way, they will exclude and not draw things outside of that depth range - which is controlled by layers in GMS 2 by default and can be set manually. So for me, and I don't know what I did to change it, but my layers had their depth changed and were falling outside of the clipping so whole layers weren't being drawn. I adjusted the clipping range and everything was fixed.

Again, doesn't exactly sound like what you were experiencing, as I think you said you tested the debug messages and they weren't showing, but given that you fixed it by switching from the matrix build funcitons to built in GM cameras it could be that or something similar. Especially since GM has a tendency to make your layers negative which your matrix build code would exclude.
 
Top