Multiple views on stage\multiple stages.

67 views
Skip to first unread message

Oren Shvalb

unread,
Dec 23, 2015, 6:17:37 PM12/23/15
to CreateJS Discussion
Hi,

In my app I have the main 'stage' object and I composited all the graphics and functionality on top of it.
At some point when player clicks on a button I need a new window to open and draw new graphics on top of it.

The questions are:

1. Can I have multiple stages?
2. If yes --> How do I switch between them or how do I make one active and the other one hidden? if 'NO' than do I need to clear the main stage every time I switch from one view to the other?

3. What is the correct way to work with multiple views?

Beginners questions.... :-)

Thank you :-)

Sebastian DeRossi

unread,
Dec 23, 2015, 6:35:53 PM12/23/15
to createjs-...@googlegroups.com
Why do you need multiple stages? 
Consider using containers. You can have multiple displayObjects within multiple containers on on stage.

Example:
var view1 = new createjs.Container();
view1.addChild(displayObject);
var view2 = new createjs.Container();
view2.addChild(displayObject1, displayObject2);
var view3 = new createjs.Container();
view3.addChild(displayObject3, displayObject4);
var view4 = new createjs.Container();
view4.addChild(displayObject5, displayObject6);

stage.addChild(view1, view2, view3, view4);

view1.alpha = 1;
view2.alpha = 0;
view3.alpha = 0;
view4.alpha = 0;

This should get you started :)


--
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.



--
<u>Sebastian DeRossi</u>

Oren Shvalb

unread,
Dec 23, 2015, 9:38:43 PM12/23/15
to createjs-...@googlegroups.com
but if I would like to display one dialog view on top of another view, How can I do that?

For example, If The user clicked on a button and I need to show like pop-up window with an error - How can I achieve that?

--
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/ySC6EIIWnkQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to createjs-discus...@googlegroups.com.

Oren Shvalb

unread,
Dec 23, 2015, 10:22:10 PM12/23/15
to CreateJS Discussion
another point, if I put all graphics in containers inside the same stage then when i call 'stage.update()' it renders everything although I only meant to render a specific container.

Isn't that bad for performance?
To unsubscribe from this group and stop receiving emails from it, send an email to createjs-discussion+unsub...@googlegroups.com.
To post to this group, send email to createjs-discussion@googlegroups.com.



--
<u>Sebastian DeRossi</u>

--
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/ySC6EIIWnkQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to createjs-discussion+unsub...@googlegroups.com.
To post to this group, send email to createjs-discussion@googlegroups.com.

Sebastian DeRossi

unread,
Dec 24, 2015, 1:51:56 AM12/24/15
to createjs-...@googlegroups.com
I am not sure I understand what you are asking?
Why couldn't the dialog be another displayObject within another layer?
Why would having all graphics within one stage be bad for performance?

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.



--
<u>Sebastian DeRossi</u>

--
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/ySC6EIIWnkQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to createjs-discus...@googlegroups.com.
To post to this group, send email to createjs-...@googlegroups.com.

--
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.

Oren Shvalb

unread,
Dec 24, 2015, 8:48:34 AM12/24/15
to CreateJS Discussion
I think (not sure) that having all graphics in the same stage is more work for CPU\GPU to render when stage.update() is called.
it's like drawing all images again on the stage. if the same stage is used for different view than it makes extra work for views that their alpha=0.

I might be conceptually wrong...What do you think?

by the way, When is it reasonable to create several stages?


Thank you.
To unsubscribe from this group and stop receiving emails from it, send an email to createjs-discussion+unsub...@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.



--
<u>Sebastian DeRossi</u>

--
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/ySC6EIIWnkQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to createjs-discussion+unsub...@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.

--
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-discussion+unsub...@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.

Sebastian DeRossi

unread,
Dec 24, 2015, 12:22:37 PM12/24/15
to createjs-...@googlegroups.com
haha No, I think you'll be okay having all your graphics on one stage :)
To tell you truth I have never needed to use more then one stage. The stage is just a container with additional functionality, but at its core its just a container for displayObjects. However there are things you can do to optimize your graphics and take a load off you CPU (ex:cache graphics)

Have a look at PlanetaryGary code, you'll see how one stage can handle many views. 

Thanks

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.



--
<u>Sebastian DeRossi</u>

--
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/ySC6EIIWnkQ/unsubscribe.
To unsubscribe from this group and all its topics, 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.

--
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.



--
<u>Sebastian DeRossi</u>

--
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.
Reply all
Reply to author
Forward
0 new messages