ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • cocos2d-x 스케쥴update, CCSpriteBatchNode
    Pause @/Cocos2d-x2 2013. 6. 30. 14:49

      this->scheduleUpdate();
        return true;
    }

    매프레임당 update함수 호출

    void HelloWorld::update(float dt){
     CCLog("update");
    }

    가상함수 update 구체화..

     

    아래는 터지후 에니메이션..이동..

    void HelloWorld::ccTouchesEnded(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent){
     CCTouch *ptouch=(CCTouch*)pTouches->anyObject();
     CCPoint location=ptouch->getLocationInView();
     location=CCDirector::sharedDirector()->convertToGL(location);
     CCSprite *pspr=(CCSprite*)this->getChildByTag(1);
     CCRect rect=pspr->boundingBox();
     if(rect.containsPoint(location)){
      CCAnimation *animation=CCAnimation::create();
      animation->setDelayPerUnit(0.3f);
      animation->addSpriteFrameWithFileName("man_0.png");
      animation->addSpriteFrameWithFileName("man_1.png");
      animation->addSpriteFrameWithFileName("man_2.png");
      animation->addSpriteFrameWithFileName("man_3.png");

      CCAnimate *animate=CCAnimate::create(animation);
      pspr->runAction(CCRepeatForever::create(animate));
      CCAction *action = CCMoveTo::create(15.0f, ccp(480, 0));
          pspr->runAction(action);
     }
    }

     

    CCSpriteBatchNode

    CCSpriteFrameCache::sharedSpriteFrameCache()->

    addSpriteFramesWithFile("grossini_gray.plist");


    CCSpriteBatchNode *sprBatch = CCSpriteBatchNode::create("grossini_gray.png");

    this->addChild(sprBatch);


    CCSprite *spr = CCSprite::createWithSpriteFrameName("grossini_dance_gray_01.png");

    spr->setPosition(ccp(i*10, i*10));

    sprBatch->addChild(spr);

    'Pause @ > Cocos2d-x2' 카테고리의 다른 글

    cocos2d-x 사운드 및  (0) 2013.06.30
    cocos2d-x transition, parallaxnode  (0) 2013.06.30
    cocos2d-x animation 정리  (0) 2013.06.30
    cocos2d-x 터치 및 스케쥴 정리  (0) 2013.06.29
    cocos2d-x 정리 2일차  (0) 2013.06.24
Designed by Tistory.