Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Custom Events - Who do they tell? — Gideros Forum

Custom Events - Who do they tell?

incipientincipient Member
edited February 2014 in General questions
Hi Everyone!

Excuse the cryptic title...

I have been using enter_frame as my "game loop" and decided to try replacing it with a custom event that is called at regular intervals (every 50ms, 20fps) to give a regular loop. I was going to benchmark these two methods (custom events vs enter_frame) once i had them both working.

I created a new class that was basically empty, but had a timer that fired a custom event (say, game_loop) and then created a new timer to call itself again and fire the event again - an infinite loop. I created an instance of this class and added it to the stage (top level object).

I went through my code and replaced all event listeners to use game_loop, not enter_frame. I figured this would work. WRONG. I can't seem to figure how custom events work. When I create the game_loop class on the same "level" as game_loop listener, ONLY that listener can hear it.

stage
|
|-->class1(child of stage)
|
|-->class2 (child of class1)
|
|-->class3 (child of class2)

If i create the game_loop class at the stage level, class1, 2, and 3 don't hear the events being fired. If i create the game_loop class at the class1 level, classes2 and 3 don't hear the events being fired. If i create the game_loop class at class3 level, then class1 and 2 don't hear the events being fired.

Can someone please explain how custom events are meant to work? I am not sure what the expected behavior is, so I do now know if i am doing something wrong!

Thank you for any help, I hope this makes sense! :)

Comments

Sign In or Register to comment.