Classes/Math/MathLesson4.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 MathLesson4::init()
{
    if ( !Layer::init() )
    {
        return false;
    }
    Size visibleSize = Director::getInstance()->getVisibleSize();
    Vec2 origin = Director::getInstance()->getVisibleOrigin();
    auto closeItem = MenuItemImage::create(
                                           "CloseNormal.png",
                                           "CloseSelected.png",
                                           CC_CALLBACK_1(MathLesson4::menuCloseCallback, this));
	closeItem->setPosition(Vec2(origin.x + visibleSize.width - closeItem->getContentSize().width/2 ,
                                origin.y + closeItem->getContentSize().height/2));
    auto menu = Menu::create(closeItem, NULL);
    menu->setPosition(Vec2::ZERO);
    this->addChild(menu, 1);
    std::string filename = "res/Sprite3D/tortoise.c3b";
    auto sprite = Sprite3D::create(filename);
    sprite->setPosition(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y);
    sprite->setScale(0.05);
    addChild(sprite);
    auto animation = Animation3D::create(filename);
    auto animate = Animate3D::createWithFrames(animation, 0, 57);
    animate->setQuality(Animate3DQuality::QUALITY_LOW);
    sprite->runAction(RepeatForever::create(animate));
    _sprite = sprite;
    float step = visibleSize.width * 0.2f;
    Vec3 p;
    p.x = step * 0.5f;
    p.y = visibleSize.height*0.2f;
    _controlPts.push_back(p);
    p.x+= step;
    p.y = visibleSize.height*0.8f;
    _controlPts.push_back(p);
    p.x += step;
    p.y = visibleSize.height*0.2f;
    _controlPts.push_back(p);
    p.x += step;
    p.y = visibleSize.height*0.8f;
    _controlPts.push_back(p);
    p.x += step;
    p.y =visibleSize.height*0.2f;
    _controlPts.push_back(p);
    _t = 0.f;
    _idx = 2;
    scheduleUpdate();
    return true;
}
bool MathLesson4 :: init ( ) { if ( ! Layer :: init ( ) ) { return false ; } Size visibleSize = Director :: getInstance ( ) -> getVisibleSize ( ) ; Vec2 origin = Director :: getInstance ( ) -> getVisibleOrigin ( ) ; auto closeItem = MenuItemImage :: create ( " " , " " , CC_CALLBACK_1 ( MathLesson4 :: menuCloseCallback , this ) ) ; closeItem -> setPosition ( Vec2 ( origin . x + visibleSize . width - closeItem -> getContentSize ( ) . width / 2 , origin . y + closeItem -> getContentSize ( ) . height / 2 ) ) ; auto menu = Menu :: create ( closeItem , NULL ) ; menu -> setPosition ( Vec2 :: ZERO ) ; this -> addChild ( menu , 1 ) ; std :: string filename = " " ; auto sprite = Sprite3D :: create ( filename ) ; sprite -> setPosition ( visibleSize . width / 2 + origin . x , visibleSize . height / 2 + origin . y ) ; sprite -> setScale ( 0.05 ) ; addChild ( sprite ) ; auto animation = Animation3D :: create ( filename ) ; auto animate = Animate3D :: createWithFrames ( animation , 0 , 57 ) ; animate -> setQuality ( Animate3DQuality :: QUALITY_LOW ) ; sprite -> runAction ( RepeatForever :: create ( animate ) ) ; _sprite = sprite ; float step = visibleSize . width * 0.2f ; Vec3 p ; p . x = step * 0.5f ; p . y = visibleSize . height * 0.2f ; _controlPts . push_back ( p ) ; p . x += step ; p . y = visibleSize . height * 0.8f ; _controlPts . push_back ( p ) ; p . x += step ; p . y = visibleSize . height * 0.2f ; _controlPts . push_back ( p ) ; p . x += step ; p . y = visibleSize . height * 0.8f ; _controlPts . push_back ( p ) ; p . x += step ; p . y = visibleSize . height * 0.2f ; _controlPts . push_back ( p ) ; _t = 0.f ; _idx = 2 ; scheduleUpdate ( ) ; return true ; }
on "init" you need to initialize your instance
on " init " you need to initialize your instance
////////////////////////////// // 1. super init first ///////////////////////////// // 2. add a menu item with "X" image, which is clicked to quit the program //    you may modify it. // add a "close" icon to exit the progress. it's an autorelease object // create menu, it's an autorelease object ///////////////////////////// // 3. add your codes below... // add a label shows "Hello World" // create and initialize a label //    sprite->setRotation3D(Vec3(0, 180, 0)); // control point