// my main code which is producing error
roll~~>runAction CCSequence::actions),
CCCallFunc::actionWithTarget),
CCJumpTo::actionWithDuration rangeY ) + minY ),( rand() rangeY ) + minY,4 ),
CCHide::action,
CCMoveTo::actionWithDuration rangeY ) + minY)),
CCShow::action(),
NULL)) );
// rest of my complete code
#include “GameScene.h”
#include “HomeScene.h”
USING_NS_CC;
CCScene* GameScene::scene()
{
// ‘scene’ is an autorelease object
CCScene *scene = CCScene::node();
// 'layer' is an autorelease object
GameScene \*layer = GameScene::node();
// add layer as a child to scene
scene-\>addChild(layer);
// return the scene
return scene;
}
// on “init” you need to initialize your instance
bool GameScene::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayerColor::initWithColor(ccc4(0,0,0,255) ))
{
return false;
}
//////////////////////////////
// 2. add your codes below...
CCSize WinSize= CCDirector::sharedDirector()-\>getWinSize();
// background
CCSprite \* bg=CCSprite::spriteWithFile("bg.png");
bg-\>setPosition(CCPointZero);
bg-\>setAnchorPoint(CCPointZero);
bg-\>setScaleX(WinSize.width/460);
bg-\>setScaleY(WinSize.height/325);
this-\>addChild(bg,0,1);
//insert roller at a random place
roll=CCSprite::spriteWithFile("ball.png");
minY = (roll-\>getContentSize().height/2)+(WinSize.height/(4.5));
maxY = (WinSize.height)- (roll-\>getContentSize().height/2);
rangeY = maxY - minY;
srand ( time(NULL) );
schedule(schedule\_selector(GameScene::CallSrand));
schedule(schedule\_selector(GameScene::tick));
actualY = ( rand() rangeY ) + minY;
CCLOG (“the actualY is oooooooooooooooooooooooooooooooooooooooooooooooooooooooo %d”,actualY);
roll~~>setPosition(ccp(20,actualY));
this~~>addChild;
// Determine random speed of the roller
minDuration = 3;
maxDuration = 7;
rangeDuration = maxDuration~~ minDuration;
actualDuration = ( rand() rangeDuration)+ minDuration;
// Create the rolling action
roll-\>runAction(CCRepeatForever::actionWithAction((CCSequence\*) CCSequence::actions(
CCCallFunc::actionWithTarget( this,callfunc\_selector(GameScene::CallSrand)),
CCCallFunc::actionWithTarget( this,callfunc\_selector(GameScene::RandomLogger)),
CCJumpTo::actionWithDuration( actualDuration,ccp(WinSize.width,( rand() rangeY ) + minY ),( rand() rangeY ) + minY,4 ),
CCHide::action(),
CCMoveTo::actionWithDuration(0,ccp(20,( rand() rangeY ) + minY)),
CCShow::action(),
NULL)) );
}
void GameScene :: tick(ccTime delta)
{
CallSrand();
}
void GameScene::CallSrand()
{
srand(time (NULL));
rand();
}
void GameScene::CallSrand(ccTime delta)
{
srand(time (NULL));
rand();
}
void GameScene::RandomLogger()
{
CCLOG (“RandomLogger %d”, rand());
int runtimeY =(rand() rangeY ) + minY;
CCLOG(“runtimeY d”, runtimeY);
}