Created
September 15, 2017 11:45
-
-
Save wapa5pow/4ee8bb63400e03e48baf137eda5f9fd9 to your computer and use it in GitHub Desktop.
9leapgist
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
// code.9leap.net default template | |
// based on enchant.js v0.7.1 | |
window.focus(); | |
enchant(); | |
window.onload = function(){ | |
var game = new Core(320, 320); | |
game.fps = 15; | |
game.preload('chara3.png','icon0.png','chara6.png'); | |
game.onload = function() { | |
game.rootScene.backgroundColor = "#000099"; | |
var player = new Sprite(32, 32); | |
player.image = game.assets['chara3.png']; | |
player.frame = 18; | |
game.rootScene.addChild(player); | |
player.x = 150; | |
player.y = 280; | |
player.addEventListener("enterframe", function() { | |
if(game.input.right) { | |
this.x += 5; | |
} | |
if (game.input.left) { | |
this.x -= 5; | |
} | |
if(game.input.up){ | |
if(game.frame % 7 === 0){ | |
tama1 = new Tama1(); | |
} | |
} | |
}); | |
var Tama1 = Class.create(Sprite, { | |
initialize: function() { | |
Sprite.call(this, 16, 16); | |
this.image = game.assets['icon0.png']; | |
this.frame = 52; | |
this.x = player.x + 8; | |
this.y = player.y; | |
game.rootScene.addChild(this); | |
}, | |
onenterframe: function() { | |
this.y -= 10; | |
if (this.y < 0) { | |
this.remove(); | |
} | |
}, | |
remove: function() { | |
game.rootScene.removeChild(this); | |
} | |
}); | |
//5.敵を出す | |
var enemy1 = new Sprite(32,32); | |
enemy1.image = game.assets['chara6.png']; | |
enemy1.frame = 3; | |
enemy1.vx = 5; | |
game.rootScene.addChild(enemy1); | |
//6.敵が画面の端に行くと跳ね返り近づく | |
}; | |
game.start(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment