CocosEditor-java 图层问题

来源:互联网 发布:linux下安装weblogic10 编辑:程序博客网 时间:2024/05/21 08:00

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


我在设计这个水管时,设计上下两水管是同一个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
原创粉丝点击