Created
February 10, 2017 08:44
-
-
Save rockos/f63da4b05d437f17dc2b8eef5e23c651 to your computer and use it in GitHub Desktop.
draw image using phina.js
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='smp3_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座標 | |
var robo = Sprite('maykid_robo').addChildTo(this); // ('usagi')内が指定したキー名に相当する | |
robo.setPosition(x_grid.center(), y_grid.center()); | |
robo.width = 300; | |
robo.height = 400; | |
}, | |
}); | |
// メイン処理 | |
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