查看: 3437|回复: 9

[已经过期] 请教大神,我这段代码绘制出的图形怎么让他在人物之下...

[复制链接]
梦石
0
星屑
50
在线时间
95 小时
注册时间
2017-4-26
回帖
30
发表于 2017-5-3 16:56:32 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
var MyBitmapAlias = Spriteset_Map.prototype.createTilemap;
Spriteset_Map.prototype.createTilemap = function() {
        if ($gameMap.mapId() == tankPos[0][2]){
        this.sprite = new Sprite();
        this.sprite.bitmap = ImageManager.loadCharacter('$Tank01');
        this.sprite.setFrame(32, 32, 32, 32);
        this.addChild(this.sprite);
        // get player's coordinate
        this.sprite.x = $gamePlayer.screenX() - ($gamePlayer.x - tankPos[0][0]) * 48 - 18;
        this.sprite.y = $gamePlayer.screenY() - ($gamePlayer.y - tankPos[0][1]) * 48 + 12;
        this.sprite.z = 2;
        }
    MyBitmapAlias.call(this);
};

如何控制sprite的图像的层级,多谢!
梦石
0
星屑
3557
在线时间
2337 小时
注册时间
2015-8-25
回帖
928

开拓者

发表于 2017-5-3 17:27:11 来自手机 | 显示全部楼层
不太懂mv
不能获取人物精灵的z之后减一么?
回复

使用道具 举报

梦石
0
星屑
4623
在线时间
1207 小时
注册时间
2016-4-7
回帖
944

开拓者

发表于 2017-5-3 17:32:46 | 显示全部楼层
本帖最后由 shitake 于 2017-5-3 17:57 编辑

由于MV的sprite没有z轴的设定,显示层级在于他们addchild时的先后顺序。
想要修改显示层级,则需要修改addchild的顺序。或者直接获取scene的children数组,然后修改。


@七重
并不能说是老式。。。只不过是实现的方式不同罢了。其实MV 没有z轴的原因是RMMV的渲染底层 pixi.js 没有z轴设定。不过目前有加z轴的意向。
具体可以参考这个issue: https://github.com/rpgtkoolmv/corescript/issues/4

点评

https://github.com/rpgtkoolmv/corescript/blob/master/js/rpg_core/Sprite.js 告诉我sprite哪里有z轴了?  发表于 2017-5-3 20:42
(゚Д゚≡゚Д゚),我用的里面明明有z,我是穿越了么……  发表于 2017-5-3 19:36

评分

参与人数 1星屑 +30 收起 理由
七重 + 30 原来如此,作为引擎意外地很老式。。?.

查看全部评分

附庸的附庸不是我的附庸,女儿的女儿还是我的女儿。CK2沉迷ing
回复

使用道具 举报

梦石
0
星屑
50
在线时间
95 小时
注册时间
2017-4-26
回帖
30
 楼主| 发表于 2017-5-3 17:36:48 | 显示全部楼层
shitake 发表于 2017-5-3 17:32
由于MV的sprite没有z轴的设定,显示层级在于他们addchild时的先后顺序。
想要修改显示层级,则需要修改addc ...

多谢大神指点
回复

使用道具 举报

梦石
2
星屑
5550
在线时间
2566 小时
注册时间
2012-2-9
回帖
947

开拓者

发表于 2017-5-3 19:34:20 | 显示全部楼层
本帖最后由 garfeng 于 2017-5-3 22:10 编辑

2017-05-03 19-27-35屏幕截图.png

绘制的怪物在人物下方。

只改了一句:this._tilemap.addChild(this.sprite);

在同一个Texture/Container(容器)里的Sprite(精灵)可通过z值来设置相互之间的高度,

但如果容器都不一样,先后顺序则取决于容器的z,

你把自己新建的精灵放在Spriteset_Map的里,那么它应该和this._baseSprite/Tilemap来比z,

如果你想仅仅让它的z比character低,那么应该把它放在Tilemap的children里,

因为character是Tilemap的children,它的z值1/3/5,只对Tilemap的children里的其他精灵有效,对Tilemap外的其他容器或精灵无效。

不知道讲清楚了没有。
[pre lang="javascript"]Spriteset_Map.prototype.createTilemap = function() {
    if (Graphics.isWebGL()) {
        this._tilemap = new ShaderTilemap();
    } else {
        this._tilemap = new Tilemap();
    }
    this._tilemap.tileWidth = $gameMap.tileWidth();
    this._tilemap.tileHeight = $gameMap.tileHeight();
    this._tilemap.setData($gameMap.width(), $gameMap.height(), $gameMap.data());
    this._tilemap.horizontalWrap = $gameMap.isLoopHorizontal();
    this._tilemap.verticalWrap = $gameMap.isLoopVertical();
    this.loadTileset();
    this._baseSprite.addChild(this._tilemap);

    this.sprite = new Sprite();
    this.sprite.bitmap = ImageManager.loadCharacter('$BigMonster1');
    this.sprite.setFrame(96, 96, 96, 96);
    this.sprite.x = ($gamePlayer.x ) * 48 - 18;
    this.sprite.y = ($gamePlayer.y ) * 48 + 12;
    this.sprite.z = 2;

    this._tilemap.addChild(this.sprite);
        // get player's coordinate
        
};[/pre]

自己弄alias吧


论如何一本正经的胡说八道



点评

多谢大神!  发表于 2017-5-4 11:06
我选择狗带  发表于 2017-5-3 21:16
无论是rmmv的官方文档还是pixi.js的文档,里面都没有z轴这种东西  发表于 2017-5-3 20:47
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部