Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tile图块截取时,间距和边距的应用有明显错误,导致地图拼接时无法吻合 #46

Open
snafour opened this issue Jul 26, 2019 · 0 comments

Comments

@snafour
Copy link

snafour commented Jul 26, 2019

tile.js 第2833行
if (this.images.length > 1) {
_spritesheet = spritesheets[tile.gid - this.firstgid];
var rect = new egret.Rectangle(0 * (this.tilewidth + this._spacing) + this._spacing, 0 * (this.tileheight + this._margin) + this._margin, this.tilewidth, this.tileheight);
}
else {
_spritesheet = spritesheets[0];
var rect = new egret.Rectangle((id % this.horizontalTileCount) * (this.tilewidth + this._spacing) + this._spacing, (Math.floor(id / this.horizontalTileCount)) * (this.tileheight + this._margin) + this._margin, this.tilewidth, this.tileheight);
}
可以看到你算rect的x位置时,代码用的是编号x间距+间距,y位置时则是编号x边距+边距
但实际上无论x还是y,都应该是编号x间距+边距(间距是两个图块直接的距离,边距是所有图块和纹理集边缘的距离),否则除非边距和间距相等,否则排版一定出现问题(结果是拼接出的地图到处都是黑线,无法互相贴合)
应该改成
if (this.images.length > 1) {
_spritesheet = spritesheets[tile.gid - this.firstgid];
var rect = new egret.Rectangle(0 * (this.tilewidth + this._spacing) + this._margin, 0 * (this.tileheight + this._spacing) + this._margin, this.tilewidth, this.tileheight);
}
else {
_spritesheet = spritesheets[0];
var rect = new egret.Rectangle((id % this.horizontalTileCount) * (this.tilewidth + this._spacing) + this._margin, (Math.floor(id / this.horizontalTileCount)) * (this.tileheight + this._spacing) + this._margin, this.tilewidth, this.tileheight);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant