What is the best way to create an event that runs every second?

19 views
Skip to first unread message

Oren Shvalb

unread,
Dec 22, 2015, 2:40:55 PM12/22/15
to CreateJS Discussion
Hi,


On my stage I have a text object that describes a timer. I would like to update it each second and decrease 1 second.

What is the best way to do it?

I can do it as follow:
1. Add Text object to Stage
2. declare a Ticker event as follow:
   
    createjs.Ticker.setFPS(1);
    createjs
.Ticker.addEventListener("tick", handleTick);


3. in the callback method, get the Text object from Stage and update its value and call stage.Update();

There must be a better way, right?

Thanks.

James Tyner

unread,
Dec 22, 2015, 2:43:14 PM12/22/15
to createjs-...@googlegroups.com
For something like this it is better to use java scripts native setinterval() method.
--
You received this message because you are subscribed to the Google Groups "CreateJS Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to createjs-discus...@googlegroups.com.
To post to this group, send email to createjs-...@googlegroups.com.
Visit this group at https://groups.google.com/group/createjs-discussion.
For more options, visit https://groups.google.com/d/optout.

Oren Shvalb

unread,
Dec 22, 2015, 2:46:12 PM12/22/15
to createjs-...@googlegroups.com
Can you tell me why? isn't there some kind of internal EaselJS's mechanism?



--
You received this message because you are subscribed to a topic in the Google Groups "CreateJS Discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/createjs-discussion/qwdKAVI62jA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to createjs-discus...@googlegroups.com.

James Tyner

unread,
Dec 22, 2015, 2:48:08 PM12/22/15
to createjs-...@googlegroups.com
Not that I know of. SetInterval() was designed for things like that... Why are you opposed to using it?

Oren Shvalb

unread,
Dec 22, 2015, 2:49:18 PM12/22/15
to createjs-...@googlegroups.com
I have nothing against setInterval(), on the contrary, I will probably use it.

Just wanted to know more about EaselJS...

Thanks :-)

Oren Shvalb

unread,
Dec 22, 2015, 2:52:37 PM12/22/15
to createjs-...@googlegroups.com
by the way, when I use SetInterval and I change the Text object, then I need to call the stage.update(); 

Right?

There is no way to render single object, you need to render the entire stage, is that correct?

James Tyner

unread,
Dec 22, 2015, 2:58:22 PM12/22/15
to createjs-...@googlegroups.com
OK good. Yeah you will want to call stage.update() as far as I know that is the only way.

Oren Shvalb

unread,
Dec 22, 2015, 3:07:22 PM12/22/15
to createjs-...@googlegroups.com
Thank you !
Reply all
Reply to author
Forward
0 new messages