Jump to content

How do I create a "stage.update ()" exclusively for the object?


luisdemarchi
 Share

Recommended Posts

On my screen I have 10 images and 6 texts. I know that every time you call "stage.update()" is redesigned view screen.

 

I have only two objects that need constant "stage.update ()". The first is a chronometer that needs every second to update a text and the second is an image that can be dragged around the screen.

 

How do I create a "stage.update ()" exclusively for the object?

 

----

 

attempts:

 

1) I made an array of "stage" for a single canvas:

canvas = document.getElementsByTagName ('canvas') [0];

stage['full'] = new createjs.Stage(canvas);

stage['chronometer'] = new createjs.Stage(canvas);

 

The problem that when executed, one deleted another :

stage ['full']. update ();

stage ['chronometer']. update ();

 

2) I tried to create Container.

containerTest = new createjs.Container();

stage.addChild(containerTest);

 

Problem? Could not update only what is in the container.

Link to comment
Share on other sites

The only way to achieve what you are trying is to create 2 separate canvas objects, layered on top of each other (they are transparent by default).

This is because the default behavior of stage.update is to clear the canvas.

 

var fullCanvas = document.getElementsById('fullCanvas');var chronometerCanvas = document.getElementsById('chronometerCanvas');var stages = {}stages['full'] = new createjs.Stage(fullCanvas);stages['chronometer'] = new createjs.Stage(chronometerCanvas);
 
Then you can call 
stages['chronometer'].update() 
without affecting the other canvas.
Link to comment
Share on other sites

 

The only way to achieve what you are trying is to create 2 separate canvas objects, layered on top of each other (they are transparent by default).

This is because the default behavior of stage.update is to clear the canvas.

 

var fullCanvas = document.getElementsById('fullCanvas');var chronometerCanvas = document.getElementsById('chronometerCanvas');var stages = {}stages['full'] = new createjs.Stage(fullCanvas);stages['chronometer'] = new createjs.Stage(chronometerCanvas);
 
Then you can call 
stages['chronometer'].update() 
without affecting the other canvas.

 

 

Could tell which is more "costly" for the system?
 
a) Create 3 canvas. 1 with everything is fixed, one with the image that allows drag and 1 with the chronometer.
 
b ) Staying giving "update" at all to update the chronometer and when the image drag.
 
I speak Portuguese-Brazilian. Translated by Google.
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...