Created
August 15, 2012 06:03
-
-
Save yonekawa/3356846 to your computer and use it in GitHub Desktop.
enchant.js issues?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.onload = function() { | |
enchant(); | |
var game = new Game(640, 960); | |
game.fps = 60; | |
game.preload('bg.jpg'); | |
game.preload('chara1.png'); | |
game.onload = function () { | |
var bg = new Sprite(640, 960); | |
bg.image = game.assets['bg.jpg']; | |
game.rootScene.addChild(bg); | |
var canvasGroup = new CanvasGroup(); | |
//game.rootScene.addChild(canvasGroup); | |
var addBear = function () { | |
var bear = new Sprite(32, 32); | |
bear.image = game.assets['chara1.png']; | |
bear.animeWaitMax = 3; | |
bear.animeWaitCount = 0; | |
bear.addEventListener('enterframe', function(evt) { | |
if (this.animeWaitCount >= this.animeWaitMax) { | |
this.animeWaitCount = 0; | |
if (bear.frame > 2) { | |
bear.frame = 0; | |
} else { | |
bear.frame++; | |
} | |
} else { | |
this.animeWaitCount++; | |
} | |
}); | |
//canvasGroup.addChild(bear); | |
game.rootScene.addChild(bear); | |
return bear; | |
}; | |
game.rootScene.addEventListener('touchend', function(evt){ | |
var bear = addBear(); | |
//bear.tl.moveTo(100, 200, 30); | |
bear.tl.rotateBy(360, 30).and().moveTo(100, 100, 30, enchant.Easing.LINEAR); | |
}); | |
}; | |
game.start(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment