CocosEditor-java 图层问题

如下图,水管应该在后面的,怎么调整遮挡关系呢?


我在设计这个水管时,设计上下两水管是同一个layer,只能同时在Ground面前或者同时在Ground之后。 

关键在于Sprite里面的zOrder是没效的,zOrder只对同级Layer的才有效。例如,下面的groundSprite放在bgPlaySrite内,无论你把ground的zOrder设的多大,都不会在柱子前显示。

<?xml version="1.0" encoding="UTF-8"?>

<Scene designWidth="720" designHeight="1280"
       positionX="0"
       positionY="0" anchorPointX="0" anchorPointY="0"
       sizeType="Percent" width="100" height="100" zorder="-1">
    <Layer zorder="0" anchorPointX="0" anchorPointY="0" sizeType="Percent" width="1" height="1" designWidth="720">

        <Component name="org.ccj.game.hello.PlayingSceneController" />
        <Sprite name="bgPlaySprite"zorder="-1" texture="textures/main.plist/bg.png"
                   positionX="0" positionY="0" anchorPointX="0" anchorPointY="0" designWidth="720" designHeight="1280"
                   sizeType="Percent"  rotation="0" width="1" height="1" >
            <Sprite zorder="10" texture="textures/flappy_packer.plist/bird1.png" positionX="204.5" positionY="747.0"
                    name="playSprite"/>
            <Sprite name="groundSprite" texture="textures/main.plist/ground.png" anchorPointX="0" anchorPointY="0"
                positionX="0" positionY="0" zorder="10"/>

        </Sprite>
        
   
    </Layer>
</Scene>

解决办法是把groundSprite独立出来,和bgPlaySprite同级,这时,zOrder=“10”就有效了

<?xml version="1.0" encoding="UTF-8"?>

<Scene designWidth="720" designHeight="1280"
       positionX="0"
       positionY="0" anchorPointX="0" anchorPointY="0"
       sizeType="Percent" width="100" height="100" zorder="-1">
    <Layer zorder="0" anchorPointX="0" anchorPointY="0" sizeType="Percent" width="1" height="1" designWidth="720">

        <Component name="org.ccj.game.hello.PlayingSceneController" />
        <Sprite zorder="-1" texture="textures/main.plist/bg.png"
                   positionX="0" positionY="0" anchorPointX="0" anchorPointY="0" designWidth="720" designHeight="1280"
                   sizeType="Percent"  rotation="0" width="1" height="1" name="bgPlaySprite">
            <Sprite zorder="10" texture="textures/flappy_packer.plist/bird1.png" positionX="204.5" positionY="747.0"
                    name="playSprite"/>

        </Sprite>
        
        <Sprite name="groundSprite" texture="textures/main.plist/ground.png" anchorPointX="0" anchorPointY="0"
                positionX="0" positionY="0" zorder="10"/>

    </Layer>
</Scene>



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值