I created a new class and added a scene to cocos2d-android, but in the main class I get this error in the class name Cannot instantiate the type Trr , where Trr is the class name. by googling, I found that the error was caused by the fact that Trr was an abstract class and could not instantiate directly. can anyone help me with this?
here is 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 is the second line in Trr where I get the error.
CCScene scene = CCScene.node(); scene.addChild(new Trr(), -1); CCDirector.sharedDirector().runWithScene(scene);
source share