PointF d = PointF.diff( to, from ); speed.set(d).normalize().scale(SPEED);
PointF d = PointF.diff( to, from ); speed.set(d).normalize().scale(SPEED);
public void reset( int from, int to, Callback callback ) { this.callback = callback; revive(); PointF pf = DungeonTilemap.tileCenterToWorld( from ); PointF pt = DungeonTilemap.tileCenterToWorld( to ); x = pf.x; y = pf.y; width = 0; height = 0; PointF d = PointF.diff( pt, pf ); PointF speed = new PointF( d ).normalize().scale( SPEED ); sx = speed.x; sy = speed.y; time = d.length() / SPEED; }
@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( 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 ); } } }
@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 ); } } }
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); } }
PointF dest = DungeonTilemap.tileToWorld( to ); PointF d = PointF.diff( dest, point() );
@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; } } }
@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 ); } } }
height = 0; PointF d = PointF.diff( to, from ); PointF speed = new PointF( d ).normalize().scale( SPEED ); sx = speed.x;
height = 0; PointF d = PointF.diff( to, from ); PointF speed = new PointF( d ).normalize().scale( SPEED ); sx = speed.x;