From 04ad0b0dfe32f60594a77ac6da03ab16988e6370 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Mon, 16 May 2022 16:03:36 -0400 Subject: [PATCH] v1.3.0: fixed rare misalignment of item sprites --- .../shatteredpixeldungeon/scenes/CellSelector.java | 9 +++++++-- .../shatteredpixeldungeon/sprites/ItemSprite.java | 6 ++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/CellSelector.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/CellSelector.java index 817c2a105..ad68be218 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/CellSelector.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/CellSelector.java @@ -131,14 +131,19 @@ public class CellSelector extends ScrollArea { SPDSettings.zoom((int) (value - PixelScene.defaultZoom)); camera.zoom( value ); - //Resets character sprite positions with the new camera zoom - //This is important as characters are centered on a 16x16 tile, but may have any sprite size + //Resets char and item sprite positions with the new camera zoom + //This is important as sprites are centered on a 16x16 tile, but may have any sprite size //This can lead to none-whole coordinate, which need to be aligned with the zoom for (Char c : Actor.chars()){ if (c.sprite != null && !c.sprite.isMoving){ c.sprite.point(c.sprite.worldToCamera(c.pos)); } } + for (Heap heap : Dungeon.level.heaps.valueList()){ + if (heap.sprite != null){ + heap.sprite.point(heap.sprite.worldToCamera(heap.pos)); + } + } return value; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/ItemSprite.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/ItemSprite.java index fee7d1773..7b0245365 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/ItemSprite.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/ItemSprite.java @@ -30,11 +30,13 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Heap; import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; +import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTilemap; import com.watabou.gltextures.SmartTexture; import com.watabou.gltextures.TextureCache; import com.watabou.glwrap.Matrix; import com.watabou.glwrap.Vertexbuffer; +import com.watabou.noosa.Camera; import com.watabou.noosa.Game; import com.watabou.noosa.MovieClip; import com.watabou.noosa.NoosaScript; @@ -134,8 +136,8 @@ public class ItemSprite extends MovieClip { final int csize = DungeonTilemap.SIZE; return new PointF( - cell % Dungeon.level.width() * csize + (csize - width()) * 0.5f, - cell / Dungeon.level.width() * csize + (csize - height()) - csize * perspectiveRaise + PixelScene.align(Camera.main, ((cell % Dungeon.level.width()) + 0.5f) * csize - width() * 0.5f), + PixelScene.align(Camera.main, ((cell / Dungeon.level.width()) + 1.0f) * csize - height() - csize * perspectiveRaise) ); }