Beispiel #1
0
Plane* Plane::create()
{
    Plane *plane = new Plane();
    auto spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName("hero1.png");
    if (plane && plane->initWithSpriteFrame(spriteFrame)) {
        plane->autorelease();
        plane->initFlyAction();
        plane->initDestroyAction();
        plane->addTouchEvent();
        return plane;
    } else {
        CC_SAFE_RELEASE(plane);
        return nullptr;
    }
}
Plane* Plane::create() {

    if (planeImgFiles->count()<=0) {
        planeImgFiles->addObject(CCString::create("p1.png"));
        planeImgFiles->addObject(CCString::create("p2.png"));
        planeImgFiles->addObject(CCString::create("p3.png"));
        planeImgFiles->addObject(CCString::create("p4.png"));
        planeImgFiles->addObject(CCString::create("p5.png"));
    }

    Plane* p = new Plane();
    planes->addObject(p);
    p->initWithFile(((CCString*)planeImgFiles->objectAtIndex(rand()%5))->getCString());
    p->autorelease();
    return p;
}