Last active
December 16, 2015 02:29
-
-
Save 2get/5362562 to your computer and use it in GitHub Desktop.
enchant.js で簡単なコントローラを作ってみた。(enchant.js触って1時間スマホで動かすよう)
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
var up = new Label(80, 40); | |
up.text = 'up'; | |
up.x = 140; | |
up.y = 240; | |
up.addEventListener('touchstart', function() { | |
game.input.up = true; | |
}); | |
up.addEventListener('touchend', function() { | |
game.input.up = false; | |
}); | |
var down = new Label(80, 40); | |
down.text = 'down'; | |
down.x = 140; | |
down.y = 280; | |
down.addEventListener('touchstart', function() { | |
game.input.down = true; | |
}); | |
down.addEventListener('touchend', function() { | |
game.input.down = false; | |
}); | |
var left = new Label(80, 40); | |
left.text = 'left'; | |
left.x = 80; | |
left.y = 260; | |
left.addEventListener('touchstart', function() { | |
game.input.left = true; | |
}); | |
left.addEventListener('touchend', function() { | |
game.input.left = false; | |
}); | |
var right = new Label(80, 40); | |
right.text = 'right'; | |
right.x = 200; | |
right.y = 260; | |
right.addEventListener('touchstart', function() { | |
game.input.right = true; | |
}); | |
right.addEventListener('touchend', function() { | |
game.input.right = false; | |
}); | |
game.rootScene.addChild(up); | |
game.rootScene.addChild(down); | |
game.rootScene.addChild(left); | |
game.rootScene.addChild(right); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment