-
-
Save tks2shimizu/12bdd010d77ba7e9b3bb to your computer and use it in GitHub Desktop.
シューティングゲームを作ろう!(2)背景のアニメーション
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
#include "GameLayer.h" | |
USING_NS_CC; | |
//シーン作成 | |
Scene* GameLayer::createScene() | |
{ | |
auto scene = Scene::create(); | |
auto layer = GameLayer::create(); | |
scene->addChild(layer); | |
return scene; | |
} | |
//初期化 | |
bool GameLayer::init() | |
{ | |
if (!Layer::init()) | |
return false; | |
//背景を表示 | |
initBackground(); | |
return true; | |
} | |
//背景を表示 | |
void GameLayer::initBackground() | |
{ | |
//画面サイズの取得 | |
Size winSize = Director::getInstance()->getWinSize(); | |
//背景の生成 | |
auto background = Sprite::create("Background.png"); | |
//背景のアンカーポイント設定 | |
background->setAnchorPoint(Vec2(0.5, 0)); | |
//背景の位置設定 | |
background->setPosition(Vec2(winSize.width / 2, 0)); | |
//背景の追加 | |
addChild(background, Z_Bg); | |
//アニメーションの作成 | |
auto movePosition = Vec2(winSize.width / 2, winSize.height - background->getContentSize().height); | |
auto move = MoveTo::create(120, movePosition); | |
//アニメーションの実行 | |
background->runAction(move); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment