Forum > C++ > Timer and Fadeout

Timer and Fadeout

By Jayden Posted 2011-07-21 13:56 Comments 3
  • Posts: 14

Hello there Cocos2d X community, this whole project seems AWESOME, if not insane.

And I like insane.

I’ve done my homework, got the whole kit working and figured out how to create new scenes. Went ahead and made myself some class templates.

Now I need your help, if you’d be so kind :3

My first question. I have two scene classes so far

The first is a Splash screen [[]]
* Loads the image
* Fades to black after 4 seconds
* -Tells app delegate to unload it, and load DisclaimerScene

DisclaimerScene [[]]
**prints the EULA
**Creates 2 buttons
* Button 1 closes the program
* Buton 2 sends me to the next page

So where I’m tripped up right now is

1) how to create a timer/fadeout for my Splash image
2) How to tell App Delegate what to do

OffTopic, is there an IRC/chat channel this community hangs out in? Any other stuff a new guy should know?
Appreciate the help in advance.

  • Posts: 1735
  • Location: Xiamen, China

#1 RE: 2011-07-21 18:55

I write a sample code for you.

    // ...
    pFullScreenSprite->runAction( CCSequence::actions( 
                                                   CCCallfunc::actionWithTarget(this, callfunc_selector(SplashLayer::switchToDisclaimerScene)),
                                                   NULL ) );
    // ...

    CCScene* pDisclaimerScene = DisclaimerScene::node();
    CCDirector::sharedDirector()->replaceScene( CCTransitionFade::transitionWithDuration(2.0f, pDisclaimerScene, ccWHITE) );

The tips:
# You can not tell AppDelegate to do, it isn’t the place to write game logics. Just tell CCDirector to do transitions, or tell your layer to do via CCCallfunc
# use CCTransitionFade or CCFadeOut to implement your feature.

Less is More. Keep Focus.

  • Posts: 14

#2 RE: 2011-07-22 11:24

Hello, and first off, thanks Walzer for your help, the support is very appreciated.

I’m getting the error ‘CCCallFunc’ has not been declared. I did make sure to use #include “CCActionInstant.h”

I’m sure it’s some simple error but I haven’t figured it out quite yet, I’ll keep you updated, thanks in advance.

  • Posts: 1735
  • Location: Xiamen, China

#3 RE: 2011-07-23 16:46

CCActionInstant.h, line 172
class CC_DLL CCCallFunc : public CCActionInstant

Your situation is a bit odd… Do you forget the namespace cocos2d:: ? Or you used my type CCCallfunc (‘f’ should be uppercase)

Less is More. Keep Focus.

Loggin to reply

Copyright © 2010 - 2013 Cocos2d-x.orgClustrmaps