Skip to content

Instantly share code, notes, and snippets.

@marvinjeng
Created September 26, 2012 06:29
Show Gist options
  • Save marvinjeng/3786442 to your computer and use it in GitHub Desktop.
Save marvinjeng/3786442 to your computer and use it in GitHub Desktop.
goog.provide('fire');
goog.require('lime.Director');
goog.require('lime.Scene');
goog.require('lime.Layer');
goog.require('lime.animation.KeyframeAnimation');
goog.require('lime.SpriteSheet');
goog.require('lime.ASSETS.fireball_hit.plist')
fire.W = 512;
fire.H = 512;
// entrypoint
fire.start = function(){
lime.scheduleManager.setDisplayRate(1000 / 60); // 60 FPS
fire.director = new lime.Director(document.body, fire.W, fire.H);
fire.director.setDisplayFPS(false);
fire.director.makeMobileWebAppCapable();
s1();
};
var s1 = function(){
var scene = new lime.Scene();
var layer = new lime.Layer().setPosition(0,0).setAnchorPoint(0,0);
var bg = new lime.Sprite().setFill('#000').setPosition(0,0).setAnchorPoint(0,0).setSize(fire.W, fire.H);
var ss = new lime.SpriteSheet('assets/fireball_hit.png', lime.ASSETS.fireball_hit.plist, lime.parser.ZWOPTEX);
var sp = new lime.Sprite().setSize(100,100).setPosition(256,256).setFill(ss.getFrame('fireball_hit_0001.png'));
var anim = new lime.animation.KeyframeAnimation();
// anim.delay = 1/3;
for(var i=1;i<=9;i++){
anim.addFrame(ss.getFrame('fireball_hit_'+goog.string.padNumber(i,4)+'.png'));
}
sp.runAction(anim);
anim.play();
layer.appendChild(bg);
layer.appendChild(sp);
scene.appendChild(layer);
fire.director.replaceScene(scene, lime.transitions.Dissolve);
};
goog.exportSymbol('fire.start', fire.start);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment