javascript - Does CreateJS contain an event listener similar to "ENTER_FRAME" in AS3? -


i trying translate effect found in "actionscript 3.0: game programming university" on html5 canvas rendering, , more specifically, create/easeljs.

this code working on:

    private var flipstep:uint;     private var isflipping:boolean = false;     private var fliptoframe:uint;      // begin flip, remember frame jump     public function startflip(fliptowhichframe:uint) {         isflipping = true;         flipstep = 10;         fliptoframe = fliptowhichframe;         this.addeventlistener(event.enter_frame, flip);     }      // take 10 steps flip     public function flip(event:event) {         flipstep--; // next step          if (flipstep > 5) { // first half of flip             this.scalex = .20*(flipstep-6);         } else { // second half of flip             this.scalex = .20*(5-flipstep);         }          // when middle of flip, go new frame         if (flipstep == 5) {             gotoandstop(fliptoframe);         }          // @ end of flip, stop animation         if (flipstep == 0) {             this.removeeventlistener(event.enter_frame, flip);         }     } 

i got halfway through before realizing requires step-by-step push every frame animate correctly. js equivalent in html5:

function fliptile(e) {     if (!tileflipping)     {         var flipstep = 30;         var sprite = e.currenttarget;         console.log(sprite);          tileflipping = true;          flipstep--;          if (flipstep > 15)         {             sprite.scalex = .02 * (flipstep-6);         } else {             sprite.scalex = .02 * (5 - flipstep);         }           if (flipstep == 0)         {             tileflipping = false;         }      } } 

the effect presents card being flipped around center, breaks , 'skews' sprite flip badly without step step. fires once, breaking flip counter. brings hunt enter_frame equivalent.. or alternate method of working this. @ moment, stumped.

not quite sure if got question right - should use createjs ticker update stuff on stage, check docs here: http://www.createjs.com/docs/easeljs/classes/ticker.html can replace event.enter_frame "tick" , keep logic same in as3 example.

internally ticker using window.requestanimationframe runs 60 times per second (= 60fps). https://developer.mozilla.org/en-us/docs/web/api/window/requestanimationframe


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -