File: example.js

Recommend this page to a friend!
  Classes of JImmy Bo   Spritesheet Animation Manager   example.js   Download  
File: example.js
Role: Example script
Content type: text/plain
Description: Example - JS
Class: Spritesheet Animation Manager
Animate graphics using CSS sprites
Author: By
Last change: Accessible
Date: 10 years ago
Size: 1,740 bytes
 

Contents

Class file image Download
var myAnim = new spritesheet_animation_manager(".player"); /* // add a sprite animation based off a row on a spritesheet myAnim.add.row ( startx_x, starty, qty, icon_size_w_px, icon_size_h_px, spacer_size_px ); myAnim.add.frame (x,y,xx,yy); // add a single frame */ /* myAnim.add.row ( 0, 0, 3, 32, 32, 0 ); */ myAnim.add.row ( 0, 32, 3, 32, 32, 0 ); /* myAnim.add.col ( 0, 0, 4, 32, 32, 0 ); */ myAnim.speed = 250; myAnim.cur.direction = 'forward'; myAnim.cur.frame = 1; // force default start frame myAnim.display.frame(); /// myAnim.looping = false; myAnim.pingpong = true; myAnim.control.play(); setTimeout( function() { myAnim.control.stop(1); // you can pass a frame to jump to on stop myAnim.display.frame(); // if you want to display the last frame, call this. // the reason why I don't have control->stop update the last displayed icon: // if user is say switching to a different animation object. So multiple // objects can be manipulating the spritesheet on an class in different ways // eg) different walking directions/styles } , 5000); // stop after 5 seconds /* setTimeout( function() { myAnim.control.play(); // you can pass a frame to jump to on stop } , 5000); // play after 5 seconds setTimeout( function() { myAnim.control.play(); // you can pass a frame to jump to on stop } ,8000); // play after 5 seconds */