Game Maker Community YoYo Games

Welcome Guest ( Log In | Register )

> Advanced Users Forum Rules

This is a Q&A forum for advanced GML users ONLY. Moderators will remove inappropriate topics. Make sure that you READ these rules prior to posting: Advanced Users Forum Rules

 
Reply to this topicStart new topic
(solved) Transition Between Draw Events, drawing overlap in one frame
Mikker
post Oct 5 2009, 02:22 PM
Post #1


GMC Member
Group Icon

Group: GMC Member
Posts: 55
Joined: 24-December 05
From: Denmark
Member No.: 41475



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.

This post has been edited by Mikker: Nov 3 2009, 08:02 PM
Go to the top of the page
 
+Quote Post
IceMetalPunk
post Oct 5 2009, 03:55 PM
Post #2


Rocker
Group Icon

Group: GMC Member
Posts: 3900
Joined: 12-March 04
From: USA
Member No.: 6970



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
Go to the top of the page
 
+Quote Post
Mikker
post Oct 5 2009, 06:11 PM
Post #3


GMC Member
Group Icon

Group: GMC Member
Posts: 55
Joined: 24-December 05
From: Denmark
Member No.: 41475



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
Go to the top of the page
 
+Quote Post
xot
post Oct 5 2009, 06:19 PM
Post #4


media multimixer
Group Icon

Group: Global Moderators
Posts: 3367
Joined: 7-May 04
From: East Coast, USA
Member No.: 9164



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.
Go to the top of the page
 
+Quote Post
Mikker
post Oct 10 2009, 08:25 PM
Post #5


GMC Member
Group Icon

Group: GMC Member
Posts: 55
Joined: 24-December 05
From: Denmark
Member No.: 41475



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)

Go to the top of the page
 
+Quote Post
Mikker
post Nov 3 2009, 08:03 PM
Post #6


GMC Member
Group Icon

Group: GMC Member
Posts: 55
Joined: 24-December 05
From: Denmark
Member No.: 41475



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!
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 23rd November 2009 - 10:49 AM