Sprite pipeBar = Sprite.create("layouts/pipeBarrier.cce");
上面这句代码触发下面的错误
cocos2d: fullPathForFilename: No file found at /cc_2x2_white_image. Possible missing file.
cocos2d: the file is not a dds file!
cocos3d: the file is not a ktx file!
Assert failed: unsupport image format!
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
原来Sprite.create()输入的是Image的file name
正确方法是:
获取Layer中的controller
private void showGameLayer() {
final ControllerMessage controller = (ControllerMessage)
NodeReader.create().showNode(owner, "layout/GameOver.cce");
controller.score = Integer.parseInt(score.getString());
setTouchEnabled(false);
pauseButton.setTouchEnabled(false);
this.playGame = false;
// FunctionFactory.callFunction("ad", "show Interstitial");
}
获取sprite
for (int a = 0; a < gold; a++) { //创建gold Sprite,然后添加到场景Scene——这是倒金子的动作。 NodeReader reader = NodeReader.create(); String goldName = "Gold" + ((int) Math.floor(Math.random() * 4) + 1) + ".cce"; Sprite sprite = reader.readSprite("layout/" + goldName); sprite.setTag(1000); sprite.setZOrder(5); sprite.setPosition(new Vec2(a * 15 + 300, 1050)); //黄金刚体 PhysicsBody physicsBody1 = sprite.getPhysicsBody(); physicsBody1.setCategoryBitmask(0x02); physicsBody1.setContactTestBitmask(0x08); owner.addChild(sprite); }