Fixes for background tile widget
This commit is contained in:
parent
fc990c12aa
commit
8d4bcf7c31
@ -77,7 +77,7 @@ export default class Field
|
||||
{
|
||||
const position = this.index >= -1
|
||||
? -this.index * this.tileset.getTileWidth()
|
||||
: (this.index % this.tileset.background.tiles) * this.tileset.getTileWidth();
|
||||
: ((this.index + 2) % this.tileset.background.tiles) * this.tileset.getTileWidth();
|
||||
|
||||
this.htmlElement.style.backgroundPositionX = String(position) + 'px';
|
||||
}
|
||||
|
@ -141,6 +141,7 @@ export default class Tilorswift
|
||||
} else {
|
||||
document.body.style.backgroundImage = 'none';
|
||||
}
|
||||
|
||||
this.map.innerHTML = '';
|
||||
this.map.appendChild(this.level.terrain.getElement());
|
||||
this.tilesetPicker.reloadTileset(this.tileset);
|
||||
|
@ -31,10 +31,13 @@ export default class BackgroundPickerWidget extends Widget
|
||||
loadTileset()
|
||||
{
|
||||
if (this.tileset.background === null) {
|
||||
this.disable();
|
||||
this.htmlElement.style.backgroundImage = 'none';
|
||||
return;
|
||||
}
|
||||
|
||||
this.enable();
|
||||
|
||||
for (let t = -2; t >= -this.tileset.background.tiles - 1; t--) {
|
||||
console.log(t);
|
||||
const button = new ButtonBackgroundTile(this.tileset, t);
|
||||
@ -79,7 +82,7 @@ export default class BackgroundPickerWidget extends Widget
|
||||
|
||||
setTile(index)
|
||||
{
|
||||
this.htmlElement.style.backgroundPosition = String(-this.tileset.getTileWidth() * index) + 'px ' + String(this.tileset.getTileHeight()) + 'px';
|
||||
this.htmlElement.style.backgroundPosition = String(((index + 2) % this.tileset.background.tiles) * this.tileset.getTileWidth()) + 'px ' + String(this.tileset.getTileHeight()) + 'px';
|
||||
}
|
||||
|
||||
getElement()
|
||||
|
Loading…
x
Reference in New Issue
Block a user