Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upgrading to latest Createjs version from May 2013 version

Tags:

createjs

This was the standard boiler plate I was using:

var stage = new createjs.Stage("canvas1");
createjs.Ticker.addEventListener("tick",stage);
stage.enableMouseOver();
...
createjs.Ticker.setFPS(12);
createjs.Ticker.addListener(stage,false);

Apparently createjs.Ticker.addListener is no longer supported. How should the above code be changed?

like image 794
Bob H Avatar asked Jan 21 '26 08:01

Bob H


1 Answers

Your example shows both the correct and deprecated usage.

// OLD
createjs.Ticker.addListener(stage,false);

// NEW
createjs.Ticker.addEventListener("tick", stage);
//OR
createjs.Ticker.on("tick", stage);

The changes make Ticker use the same Event dispatcher pattern that the rest of CreateJS does.

Additionally, the framerate method has changed to a setter:

// OLD
createjs.Ticker.setFPS(12);

// NEW
createjs.Ticker.framerate = 12; 

It will depend on what version you use of EaselJS. I updated the demo you posted to the latest version using those changes: http://jsfiddle.net/lannymcnie/Aprdf/80/

Unfortunately there are still demos out there with out-of-date code. Let me know if you have any other questions.

like image 57
Lanny Avatar answered Jan 23 '26 04:01

Lanny



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!