CocosEditor-java错误解决cocos2d: the file is not a dds file!

 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);
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值