Created
March 18, 2017 01:36
-
-
Save rockos/735a13e51f2b2d895a7556afa959439d to your computer and use it in GitHub Desktop.
delete many robots
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
<!doctype html> | |
<html> | |
<head> | |
<meta charset='utf-8' /> | |
<meta name="viewport" content="width=device-width, user-scalable=no" /> | |
<meta name="apple-mobile-web-app-capable" content="yes" /> | |
<title>Getting started | phina.js</title> | |
<!-- phina.js を読み込む --> | |
<script src='http://cdn.rawgit.com/phi-jp/phina.js/v0.2.0/build/phina.js'></script> | |
<!-- メイン処理 --> | |
<script src='smp5_main.js'></script> | |
</head> | |
<body> | |
</body> | |
</html>> |
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
// phina.js をグローバル領域に展開 | |
phina.globalize(); | |
var img = { | |
image: {'maykid_robo': 'robo.png'} | |
}; | |
// MainScene クラスを定義 | |
phina.define('MainScene', { | |
superClass: 'DisplayScene', | |
init: function() { | |
this.superInit(); | |
// 背景色を指定 | |
this.backgroundColor = '#444'; | |
var x_grid = this.gridX; // x座標 | |
var y_grid = this.gridY; // y座標 | |
// n 回繰り返す | |
(12).times(function() { | |
var robo = Sprite('maykid_robo').addChildTo(this); // ('usagi')内が指定したキー名に相当する | |
robo.setPosition(x_grid.center(), y_grid.center()); | |
robo.width = 80; | |
robo.height = 100; | |
// 位置をランダムに設定 | |
robo.x = Random.randint(0, 640); | |
robo.y = Random.randint(0, 960); | |
// タッチ判定を有効に | |
robo.setInteractive(true); | |
// タッチ終了時に発火 | |
robo.onpointend = function() { | |
// 自身を削除 | |
this.remove(); | |
}; | |
}, this); | |
} | |
}); | |
// メイン処理 | |
phina.main(function() { | |
// アプリケーション生成 | |
var app = GameApp({ | |
startLabel: 'main', // メインシーンから開始する | |
assets: img | |
}); | |
// アプリケーション実行 | |
app.run(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment