Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.2.4 Spriteの設置 #9

Open
niku opened this issue Feb 15, 2015 · 0 comments
Open

4.2.4 Spriteの設置 #9

niku opened this issue Feb 15, 2015 · 0 comments

Comments

@niku
Copy link
Owner

niku commented Feb 15, 2015

cocos2d-x と対比するとそれなりに書くことがある.

Director の取得

Directorクラスはシングルトンクラスになっているため、Director::getInstance()で取り出して使います

cocos2d-js でどうやるとよいかは Director の説明に書いてある.

cocos2d-js では最初から director オブジェクトへアクセスする.そのときのアクセスは cc.director になる.

Sptirte の生成

例によって Sprite.create() ではなく new Sprite() を利用する.
引数には画像として利用するファイル名を指定する.

cocos2d-js では読み込まれていないリソースを利用するのを防止するため,
スプライトにファイル名を直接指定せず,
resource.js で指定したオブジェクト res.xxx を経由してファイル名を取得するのが行儀がよさそうだ.

サンプルでもそのようになっていた.

cocos2d-x の Vec2 相当の cc.Point

cocos2d-x では座標の指定に Vec2 を使っている.
cocos2d-x 本の「3.4.4 ノードの位置の移動」に詳しい.
本にも記述があるとおり,Vec2 の別名は Point となっている.
これら 2 つは同じものを指している.

cocos2d-js では Vec2 はなく cc.Point オブジェクトがそれに相当する.
Point オブジェクトを作るときは new Point ではなく cc.p を使うこと.
Point オブジェクトの API リファレンス

please do not use its constructor to create points, use cc.p() alias function instead.
と書いてある

画面の向きの指定

cocos2d-js を用いて web で表示すると,初期状態でも特に問題なく表示された.

niku added a commit that referenced this issue Feb 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant