Search code examples
androidcocos2d-iphonebeziercocos2d-android

CCbezierTo not working in cocos2d ,android


I want my sprite to move from one point to another point in a curve path, so i am using Bezierto in my code, but it doesnt seems to work out as it shows an error on bezier keyword (The local variable bezier may not have been initialized). please help me.

my code is as follows

//initial point of sprite
sprite1pos=CGPoint.ccp((winSize.width/2+winSize.width/2),0);

//now the bezier config declaration

    CCBezierConfig bezier;
bezier.controlPoint_1=CGPoint.ccp(sprite1pos.x,sprite1pos.y);
bezier.controlPoint_2=CGPoint.ccp(winSize.width/2,winSize.height/2);
bezier.endPosition=CGPoint.ccp(0,0);

 CCBezierTo  action = CCBezierTo.action(3, bezier);
   sprite1.runAction(action);

Solution

  • You need to initialize your bezier variable.

    The line :

     CCBezierConfig bezier;
    

    Does not initialize the bezier variable.

    It should be :

    CCBezierConfig  bezier = new CCBezierConfig(<arguments if any>);