frameworks/runtime-src/Classes/HelloWorldScene.cpp
// on "init" you need to initialize your instance
on "init" you need to initialize your instance
on " init " you need to initialize your instance
bool HelloWorld::init()
{
    if ( !Layer::init() )
    {
        return false;
    }
    Size visibleSize = Director::getInstance()->getVisibleSize();
    Vec2 origin = Director::getInstance()->getVisibleOrigin();
    auto sprite = Sprite::create("HelloWorld.png");
    sprite->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
    this->addChild(sprite, 0);
    if(true)
    {
        {
            auto alien = SpriteWithHue::create("res/alien.png");
            alien->setPosition(Vec2((visibleSize.width + origin.x) * CCRANDOM_0_1(), (visibleSize.height + origin.y) * CCRANDOM_0_1()));
            alien->setHue(2 * M_PI * 0.5);
            this->addChild(alien,1);
        }
    }
    else Animation
    {
        for (int i=0; i<30; i++) {
            SpriteFrameCache::getInstance()->addSpriteFramesWithFile("grossini-aliases.plist", "grossini-aliases.png");
            Vector<SpriteFrame*> animFrames(15);
            char str[100] = {0};
            for(int i = 1; i < 15; i++)
            {
                sprintf(str, "dance_%02d", i);
                auto frame = SpriteFrameCache::getInstance()->getSpriteFrameByName(str);
                animFrames.pushBack(frame);
            }
            auto animation = Animation::createWithSpriteFrames(animFrames, 0.3f);
            auto _grossini = SpriteWithHue::createWithSpriteFrameName("grossini_dance_01.png");
            _grossini->setHue(2 * M_PI * CCRANDOM_0_1());
            _grossini->setPosition(Vec2((visibleSize.width + origin.x) * CCRANDOM_0_1(), (visibleSize.height + origin.y) * CCRANDOM_0_1()));
            _grossini->runAction(RepeatForever::create(Animate::create(animation)));
            this->addChild(_grossini,1);
        }
    }
    return true;
}
bool HelloWorld :: init ( ) { if ( ! Layer :: init ( ) ) { return false ; } Size visibleSize = Director :: getInstance ( ) -> getVisibleSize ( ) ; Vec2 origin = Director :: getInstance ( ) -> getVisibleOrigin ( ) ; auto sprite = Sprite :: create ( " " ) ; sprite -> setPosition ( Vec2 ( visibleSize . width / 2 + origin . x , visibleSize . height / 2 + origin . y ) ) ; this -> addChild ( sprite , 0 ) ; if ( true ) { { auto alien = SpriteWithHue :: create ( " " ) ; alien -> setPosition ( Vec2 ( ( visibleSize . width + origin . x ) * CCRANDOM_0_1 ( ) , ( visibleSize . height + origin . y ) * CCRANDOM_0_1 ( ) ) ) ; alien -> setHue ( 2 * M_PI * 0.5 ) ; this -> addChild ( alien , 1 ) ; } } else { for ( int i = 0 ; i < 30 ; i ++ ) { SpriteFrameCache :: getInstance ( ) -> addSpriteFramesWithFile ( " " , " " ) ; Vector < SpriteFrame * > animFrames ( 15 ) ; char str [ 100 ] = { 0 } ; for ( int i = 1 ; i < 15 ; i ++ ) { sprintf ( str , " " , i ) ; auto frame = SpriteFrameCache :: getInstance ( ) -> getSpriteFrameByName ( str ) ; animFrames . pushBack ( frame ) ; } auto animation = Animation :: createWithSpriteFrames ( animFrames , 0.3f ) ; auto _grossini = SpriteWithHue :: createWithSpriteFrameName ( " " ) ; _grossini -> setHue ( 2 * M_PI * CCRANDOM_0_1 ( ) ) ; _grossini -> setPosition ( Vec2 ( ( visibleSize . width + origin . x ) * CCRANDOM_0_1 ( ) , ( visibleSize . height + origin . y ) * CCRANDOM_0_1 ( ) ) ) ; _grossini -> runAction ( RepeatForever :: create ( Animate :: create ( animation ) ) ) ; this -> addChild ( _grossini , 1 ) ; } } return true ; }
on "init" you need to initialize your instance
on " init " you need to initialize your instance
////////////////////////////// // 1. super init first // add "HelloWorld" splash screen" // position the sprite on the center of the screen // add the sprite as a child to this layer //SpriteWithHue //        for(int i=0; i<30; i++) //SpriteWithHue Animation