Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- auto label = Label::createWithTTF("Hello World", "fonts/Marker Felt.ttf", 24); //label 1
- auto vecLabel = Vec2(visibleSize.width / 2, visibleSize.height - label->getContentSize().height);
- label->setPosition(vecLabel);
- auto label2 = Label::createWithTTF("GAME", "fonts/Marker Felt.ttf", 30); //label 2
- label2->setPosition(100, 200);
- // position the label on the center of the screen
- label->setPosition(Vec2(origin.x + visibleSize.width/2, origin.y + visibleSize.height - label->getContentSize().height));
- // add the label as a child to this layer
- this->addChild(label, 1);
- this->addChild(label2, 1);
- // add "HelloWorld" splash screen"
- auto sprite = Sprite::create("HelloWorld.png");
- auto vecSprite = Vec2(visibleSize.width / 2, visibleSize.height / 2);
- sprite->setPosition(vecSprite);
- // position the sprite on the center of the screen
- sprite->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
- // add the sprite as a child to this layer
- this->addChild(sprite, 0);
- // exercise 02 sprite
- cocos2d::Sprite* dSprite = cocos2d::Sprite::create("dog-animate.png");
- dSprite->setPosition(Vec2(200, 50));
- dSprite->setRotation(40);
- dSprite->setScale(2.0);
- //actions
- auto fadeIn = FadeIn::create(1.0f);
- dSprite->runAction(fadeIn);
- auto moveBy = MoveBy::create(2, Vec2(200, 100));
- dSprite->runAction(moveBy);
- auto moveTo = MoveTo::create(2, Vec2(200, 100));
- dSprite->runAction(moveTo);
- dSprite->setRotation(30);
- dSprite->setScale(4.0f);
- auto fadeOut = FadeOut::create(2.0f);
- dSprite->runAction(fadeOut);
- //question2
- auto bSprite = Sprite::create("bluemansprite.png");
- auto moveBy = MoveBy::create(2, Vec2(200, 0));
- bSprite->runAction(moveBy);
- auto moveTo = MoveTo::create(2, Vec2(200, 50));
- bSprite->runAction(moveTo);
- auto moveTo = MoveTo::create(2, Vec2(200, 100));
- bSprite->runAction(moveTo);
- auto moveTo = MoveTo::create(2, Vec2(200, 150));
- bSprite->runAction(moveTo);
- auto moveTo = MoveTo::create(2, Vec2(200, 200));
- bSprite->runAction(moveTo);
- auto moveTo = MoveTo::create(2, Vec2(250, 100));
- bSprite->runAction(moveTo);
- return true;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement