Created
July 18, 2014 06:31
-
-
Save omas/045312706f1a65f8a1bb to your computer and use it in GitHub Desktop.
This file contains hidden or 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(); | |
| var game; | |
| var gs = {fps:30}; | |
| gs.window = { | |
| height:320 | |
| ,width:320 | |
| } | |
| gs.assets = {}; | |
| var STATUS = { | |
| WAIT:0 | |
| ,WALK:1 | |
| ,JUMP:2 | |
| } | |
| var eCore = enchant.Class.create(enchant.Core,{ | |
| initialize:function(color){ | |
| enchant.Core.call(this,gs.window.width,gs.window.height); | |
| this.fps = gs.fps; | |
| this.stage = this.rootScene; | |
| this.stage.backgroundColor = color || "white"; | |
| } | |
| }); | |
| var ePad = enchant.Class.create(enchant.ui.Pad,{ | |
| initialize:function(){ | |
| enchant.ui.Pad.call(this); | |
| this.x = 0; | |
| this.y = 220; | |
| game.stage.addChild(this); | |
| } | |
| }); | |
| gs.assets.bear = { | |
| height:32 | |
| ,width:32 | |
| ,path:"images/chara1.png" | |
| }; | |
| var eBear = enchant.Class.create(enchant.Sprite,{ | |
| initialize:function(){ | |
| enchant.Sprite.call(this,gs.assets.bear.width,gs.assets.bear.height); | |
| this.image = game.assets[gs.assets.bear.path]; | |
| this.frame = 10; | |
| this.status = STATUS.WAIT; | |
| this.moveCenter(); | |
| game.stage.addChild(this); | |
| } | |
| ,moveCenter:function(){ | |
| this.moveTo( | |
| ~~((gs.window.width - this.width) / 2) | |
| ,~~((gs.window.height - this.height) / 2) | |
| ); | |
| } | |
| }); | |
| window.onload = function(){ | |
| game = new eCore("yellow"); | |
| game.preload( | |
| "pad.png", "apad.png", "icon0.png", "font0.png" | |
| ,gs.assets.bear.path | |
| ); | |
| game.onload = function(){ | |
| var pad = new ePad(); | |
| var bear = new eBear(); | |
| }; | |
| game.start(); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment