v0.4.1: corrected alignment issues with character sprites
This commit is contained in:
parent
e7bee83f35
commit
026a1a9e2e
|
@ -22,6 +22,8 @@ package com.shatteredpixel.shatteredpixeldungeon.scenes;
|
||||||
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.DungeonTilemap;
|
import com.shatteredpixel.shatteredpixeldungeon.DungeonTilemap;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||||
import com.watabou.input.Touchscreen.Touch;
|
import com.watabou.input.Touchscreen.Touch;
|
||||||
import com.watabou.noosa.TouchArea;
|
import com.watabou.noosa.TouchArea;
|
||||||
import com.watabou.utils.GameMath;
|
import com.watabou.utils.GameMath;
|
||||||
|
@ -55,6 +57,24 @@ public class CellSelector extends TouchArea {
|
||||||
(int)touch.current.y ) );
|
(int)touch.current.y ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private float zoom( float value ) {
|
||||||
|
|
||||||
|
value = GameMath.gate( PixelScene.minZoom, value, PixelScene.maxZoom );
|
||||||
|
ShatteredPixelDungeon.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
|
||||||
|
//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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
public void select( int cell ) {
|
public void select( int cell ) {
|
||||||
if (enabled && listener != null && cell != -1) {
|
if (enabled && listener != null && cell != -1) {
|
||||||
|
@ -103,9 +123,7 @@ public class CellSelector extends TouchArea {
|
||||||
|
|
||||||
pinching = false;
|
pinching = false;
|
||||||
|
|
||||||
int zoom = Math.round( camera.zoom );
|
zoom(Math.round( camera.zoom ));
|
||||||
camera.zoom( zoom );
|
|
||||||
ShatteredPixelDungeon.zoom((int) (zoom - PixelScene.defaultZoom));
|
|
||||||
|
|
||||||
dragging = true;
|
dragging = true;
|
||||||
if (t == touch) {
|
if (t == touch) {
|
||||||
|
@ -163,9 +181,7 @@ public class CellSelector extends TouchArea {
|
||||||
if (pinching){
|
if (pinching){
|
||||||
pinching = false;
|
pinching = false;
|
||||||
|
|
||||||
int zoom = Math.round( camera.zoom );
|
zoom( Math.round( camera.zoom ) );
|
||||||
camera.zoom( zoom );
|
|
||||||
ShatteredPixelDungeon.zoom((int) (zoom - PixelScene.defaultZoom));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,8 @@ import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfInvisibili
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||||
|
import com.watabou.noosa.Camera;
|
||||||
import com.watabou.noosa.Game;
|
import com.watabou.noosa.Game;
|
||||||
import com.watabou.noosa.MovieClip;
|
import com.watabou.noosa.MovieClip;
|
||||||
import com.watabou.noosa.Visual;
|
import com.watabou.noosa.Visual;
|
||||||
|
@ -117,8 +119,8 @@ public class CharSprite extends MovieClip implements Tweener.Listener, MovieClip
|
||||||
final int csize = DungeonTilemap.SIZE;
|
final int csize = DungeonTilemap.SIZE;
|
||||||
|
|
||||||
return new PointF(
|
return new PointF(
|
||||||
((cell % Level.WIDTH) + 0.5f) * csize - width * 0.5f,
|
PixelScene.align(Camera.main, ((cell % Level.WIDTH) + 0.5f) * csize - width * 0.5f),
|
||||||
((cell / Level.WIDTH) + 1.0f) * csize - height
|
PixelScene.align(Camera.main, ((cell / Level.WIDTH) + 1.0f) * csize - height)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user