Created
March 28, 2014 10:36
-
-
Save rinsuki/9829819 to your computer and use it in GitHub Desktop.
熊がぐるぐる回る
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
熊がぐるぐる回ります。 | |
enchant.js(ver0.8.0)使用。 |
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
* { | |
margin: 0; | |
padding: 0; | |
border: 0; | |
} | |
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
enchant(); | |
url="http://enchantjs.com/assets/images/chara1.gif"; | |
window.onload=function() { | |
var game= new Game(320,320); | |
game.fps=30; | |
game.preload(url); | |
game.onload=function() { | |
var kuma=new Sprite(32,32); | |
kuma.image=game.assets[url]; | |
kuma.x=0; | |
kuma.y=0; | |
spead=1; | |
count=0; | |
anime=new Array(1,2); | |
game.rootScene.addChild(kuma); | |
game.rootScene.backgroundColor="#7ecef4"; | |
game.rootScene.addEventListener(Event.ENTER_FRAME,function() { | |
kuma.x += spead; | |
if (kuma.x>=(320-32)) { | |
spead=-1; | |
kuma.scaleX=-1; | |
} | |
if (kuma.x<=0) { | |
spead=1; | |
kuma.scaleX=1; | |
} | |
kuma.frame=anime[Math.floor(count)]; | |
count=(count+0.25)%2; | |
kuma.rotate(40); | |
}); | |
}; | |
game.start(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment