public int screenToTile( int x, int y ) { Point p = camera().screenToCamera( x, y ). offset( this.point().negate() ). invScale( SIZE ). floor(); return p.x >= 0 && p.x < Level.WIDTH && p.y >= 0 && p.y < Level.HEIGHT ? p.x + p.y * Level.WIDTH : -1; }
@Override protected void onDrag( Touch t ) { camera.target = null; if (pinching) { float curSpan = PointF.distance( touch.current, another.current ); camera.zoom( GameMath.gate( PixelScene.minZoom, startZoom * curSpan / startSpan, PixelScene.maxZoom ) ); } else { if (!dragging && PointF.distance( t.current, t.start ) > dragThreshold) { dragging = true; lastPos.set( t.current ); } else if (dragging) { camera.scroll.offset( PointF.diff( lastPos, t.current ).invScale( camera.zoom ) ); lastPos.set( t.current ); } } }
private void doScroll(PointF current) { final Camera c = content.camera; c.scroll.offset( PointF.diff(lastPos, current).invScale( c.zoom ) ); if (c.scroll.x + width > content.width()) { c.scroll.x = content.width() - width; } if (c.scroll.x < 0) { c.scroll.x = 0; } if (c.scroll.y + height > content.height()) { c.scroll.y = content.height() - height; } if (c.scroll.y < 0) { c.scroll.y = 0; } thumb.y = y + height * c.scroll.y / content.height(); lastPos.set(current); } }
@Override protected void onDrag( Touch t ) { camera.target = null; if (pinching) { float curSpan = PointF.distance( touch.current, another.current ); float zoom = (startZoom * curSpan / startSpan); camera.zoom( GameMath.gate( PixelScene.minZoom, zoom - (zoom % 0.1f), PixelScene.maxZoom ) ); } else { if (!dragging && PointF.distance( t.current, t.start ) > dragThreshold) { dragging = true; lastPos.set( t.current ); } else if (dragging) { camera.scroll.offset( PointF.diff( lastPos, t.current ).invScale( camera.zoom ) ); lastPos.set( t.current ); } } }
@Override protected void onDrag( NoosaInputProcessor.Touch t ) { camera.target = null; if (pinching) { float curSpan = PointF.distance( touch.current, another.current ); float zoom = (startZoom * curSpan / startSpan); camera.zoom( GameMath.gate( PixelScene.minZoom, zoom - (zoom % 0.1f), PixelScene.maxZoom ) ); } else { if (!dragging && PointF.distance( t.current, t.start ) > dragThreshold) { dragging = true; lastPos.set( t.current ); } else if (dragging) { camera.scroll.offset( PointF.diff( lastPos, t.current ).invScale( camera.zoom ) ); lastPos.set( t.current ); } } }
@Override protected void onDrag( Touch t ) { if (dragging) { Camera c = content.camera; c.scroll.offset( PointF.diff( lastPos, t.current ).invScale( c.zoom ) ); if (c.scroll.x + width > content.width()) { c.scroll.x = content.width() - width; } if (c.scroll.x < 0) { c.scroll.x = 0; } if (c.scroll.y + height > content.height()) { c.scroll.y = content.height() - height; } if (c.scroll.y < 0) { c.scroll.y = 0; } indicator.y = y + height * c.scroll.y / content.height(); lastPos.set( t.current ); } else if (PointF.distance( t.current, t.start ) > dragThreshold) { indicator.am = INDICATOR_SOLID; dragging = true; lastPos.set( t.current ); } } }
@Override protected void onDrag( Touch t ) { if (dragging) { Camera c = content.camera; c.scroll.offset( PointF.diff( lastPos, t.current ).invScale( c.zoom ) ); if (c.scroll.x + width > content.width()) { c.scroll.x = content.width() - width; } if (c.scroll.x < 0) { c.scroll.x = 0; } if (c.scroll.y + height > content.height()) { c.scroll.y = content.height() - height; } if (c.scroll.y < 0) { c.scroll.y = 0; } thumb.y = y + height * c.scroll.y / content.height(); lastPos.set( t.current ); } else if (PointF.distance( t.current, t.start ) > dragThreshold) { dragging = true; lastPos.set( t.current ); thumb.am = 1; } } }
public int screenToTile(int x, int y, boolean wallAssist ) { PointF p = camera().screenToCamera( x, y ). offset( this.point().negate() ). invScale( SIZE ); //snap to the edges of the tilemap p.x = GameMath.gate(0, p.x, Dungeon.level.width()-0.001f); p.y = GameMath.gate(0, p.y, Dungeon.level.height()-0.001f); int cell = (int)p.x + (int)p.y * Dungeon.level.width(); if (wallAssist && map != null && DungeonTileSheet.wallStitcheable(map[cell])){ if (cell + mapWidth < size && p.y % 1 >= 0.75f && !DungeonTileSheet.wallStitcheable(map[cell + mapWidth])){ cell += mapWidth; } } return cell; }
public int screenToTile(int x, int y, boolean wallAssist ) { PointF p = camera().screenToCamera( x, y ). offset( this.point().negate() ). invScale( SIZE ); //snap to the edges of the tilemap p.x = GameMath.gate(0, p.x, Dungeon.level.width()-0.001f); p.y = GameMath.gate(0, p.y, Dungeon.level.height()-0.001f); int cell = (int)p.x + (int)p.y * Dungeon.level.width(); if (wallAssist && map != null && DungeonTileSheet.wallStitcheable(map[cell])){ if (cell + mapWidth < size && p.y % 1 >= 0.75f && !DungeonTileSheet.wallStitcheable(map[cell + mapWidth])){ cell += mapWidth; } } return cell; }