4

I created new class and added scene in cocos2d-android but in main class getting this error in class name Cannot instantiate the type Trr where Trr is the name of the class. by googling i found the error was due to Trr was abstract class and directly cannot instantiate. can anybody help me in this?

here's the whole code

**public abstract class Trr extends CCLayer{

public static CCScene scene()
{
    CCScene scene = CCScene.node();
    CCLayer layer = new GameL();
    scene.addChild(layer);  
    return scene;     
}

    CCTextureAtlas atlas;

    static final int kTagNode = 1;
    static final int kTagGrossini = 2;

    public void Trr() {
        CGSize s = CCDirector.sharedDirector().winSize();

        CCLabel label = CCLabel.makeLabel(title(), "DroidSans", 18);
        label.setPosition(s.width / 2, s.height - 30);
        addChild(label, 1);

        CCMenuItemImage item1 = CCMenuItemImage.item("b1.png", "b2.png", this, "backCallback");
        CCMenuItemImage item2 = CCMenuItemImage.item("r1.png", "r2.png", this, "restartCallback");
        CCMenuItemImage item3 = CCMenuItemImage.item("f1.png", "f2.png", this, "nextCallback");

        CCMenu menu = CCMenu.menu(item1, item2, item3);
        menu.setPosition(0, 0);
        item1.setPosition(s.width / 2 - 100, 30);
        item2.setPosition(s.width / 2, 30);
        item3.setPosition(s.width / 2 + 100, 30);
        addChild(menu, 1);
    }

    public abstract String title();
}

**

MainActivity- 2nd line at Trr where i'm getting error.

CCScene scene = CCScene.node();
    scene.addChild(new Trr(), -1); 
    CCDirector.sharedDirector().runWithScene(scene);
4

1 に答える 1