Help - Search - Members - Calendar
Full Version: (solved) Transition Between Draw Events
Game Maker Community > Working with Game Maker > Advanced Users Only
Mikker
Hey,

I'm having some problems with my Draw events.

Right now I'm using a custom transition, where two surfaces are drawn in the draw event and moved. After this transition is complete, it returns to the game in the new room. This works fine.

I have recently succeeded in making a brightness system using blend modes, where I add/subtract colors in the Draw event. This also works fine.

The object i use for the brightness system is deactivated during the transition, and the brightness system is incorporated into the transition object instead. Herein lies the problem.

The problem is a single frame in the transition between the two (after the transition, initiation of the room). Either the brightness system triggers twice (once atop of the previous image already brightened), or the objects in the room will lack the brightness system for that one frame (where the objects are drawn over the last transition frame that uses brightness).

After moving the different actions around, I've come to the conclusion, that I need to be able to redraw the image after clearing it. To this effect, I use draw_clear, then screen_redraw. However, because this is in the middle of a draw event, it results in a very visible clearing of the screen right before the frame.

Here is the code i use. I've truncated it down to the essential overlap. The transition object is a loop that ends with clearing the surfaces, not doing brightness for the final step, and initiating the normal screen object. It is this frame that is problematic.

Version 1: background working correct, but with objects missing brightness:

CODE
Transition Object:

(rest of transition)

surface_free(s1)
surface_free(s2)

instance_destroy()
instance_activate_object(ScreenController)
ScreenController.nodraw = 1
exit

ScreenObject:

if nodraw = 1
{nodraw = 0
instance_activate_all()}
else

(rest of non-transition)


Version 2: objects working, but with background getting double-brightness:

CODE
Transition Object:

(rest of transition)

surface_free(s1)
surface_free(s2)

instance_destroy()
instance_activate_all()
ScreenController.nodraw = 1
exit

ScreenObject:

if nodraw = 1
{nodraw = 0}
else

(rest of non-transition)


Version 3: Both objects and background works, but black flash before frame.

CODE
Transition Object:

(rest of transition)

surface_free(s1)
surface_free(s2)

instance_destroy()
instance_activate_all()
ScreenController.nodraw = 1
draw_clear_alpha(c_black,0)
screen_redraw()
exit

ScreenObject:

if nodraw = 1
{nodraw = 0}
else

(rest of non-transition)


Any solution for this? Is this really extraordinarily simple? I want to use the last one, but I really want to get rid of that annoying flash.
IceMetalPunk
I haven't looked at your code, to be honest, but I'd like to start with a question: Why are you designing your own transition system instead of using GM's nice built-in transition_define() function?

I ask because if you can use transition_define, it will call the draw events in both rooms for you, thus allowing your original brightness object to handle everything normally without needing special cases for before, during, and after a transition.

-IMP wink1.gif smile.gif
Mikker
QUOTE (IceMetalPunk @ Oct 5 2009, 05:55 PM) *
I haven't looked at your code, to be honest, but I'd like to start with a question: Why are you designing your own transition system instead of using GM's nice built-in transition_define() function?

I ask because if you can use transition_define, it will call the draw events in both rooms for you, thus allowing your original brightness object to handle everything normally without needing special cases for before, during, and after a transition.

-IMP wink1.gif smile.gif


My transitions are a little more complicated than moving two surfaces around. I have objects that needs to transfer over, and I use animated backgrounds and in one transition I have over 25 surfaces drawn atop of each other. I took a look at transition_define(), and it really doesn't look like it supports any of that.

I am also not ready to go and retroactively destroy a part of the game I finally manage to nail completely unsure.gif
xot
Well, I wouldn't dismiss the built-in transition engine completely, there is almost no limit to what you can do, but from the sounds of it you'd probably have to make major changes.

QUOTE
After moving the different actions around, I've come to the conclusion, that I need to be able to redraw the image after clearing it. To this effect, I use draw_clear, then screen_redraw. However, because this is in the middle of a draw event, it results in a very visible clearing of the screen right before the frame.


Try disabling the background color in the room(s). If required, add a background object which can clear the screen when you need it, and can be disabled when you don't.
Mikker
I tried to add an object to do screen_redraw outside the draw event, but it only seemed to make things worse.

Then I tried something different, by having screen_redraw not be next to the draw_clear. But then the game hangs. Why is that, and can it be solved?

Code:

CODE
Transition Object:

(rest of transition)

surface_free(s1)
surface_free(s2)

draw_clear(c_black)
instance_activate_all()
ScreenController.nodraw = 1
instance_destroy()
exit

ScreenObject:

if nodraw = 1
{screen_redraw()
nodraw = 0}
else

(rest of non-transition)

Mikker
Solved it, finally.

Managed to postpone the issue a single frame right after the transition. Then it was simply a matter of hiding that frame with a surface.

Thanks for the input!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.