com.watabou.input.Touchscreen.Touch Java Examples
The following examples show how to use
com.watabou.input.Touchscreen.Touch.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CellSelector.java From YetAnotherPixelDungeon with GNU General Public License v3.0 | 6 votes |
@Override protected void onTouchDown( Touch t ) { if (t != touch && another == null) { if (!touch.down) { touch = t; onTouchDown( t ); return; } pinching = true; another = t; startSpan = PointF.distance( touch.current, another.current ); startZoom = camera.zoom; dragging = false; } }
Example #2
Source File: CellSelector.java From remixed-dungeon with GNU General Public License v3.0 | 6 votes |
@Override protected void onTouchDown( Touch t ) { if (t != touch && another == null) { if (!touch.down) { touch = t; onTouchDown( t ); return; } pinching = true; another = t; startSpan = PointF.distance( touch.current, another.current ); startZoom = camera.zoom; dragging = false; } }
Example #3
Source File: CellSelector.java From remixed-dungeon with GNU General Public License v3.0 | 6 votes |
@Override protected void onTouchUp( Touch t ) { if (pinching && (t == touch || t == another)) { pinching = false; int zoom = Math.round( camera.zoom ); camera.zoom( zoom ); RemixedDungeon.zoom(zoom - PixelScene.defaultZoom); dragging = true; if (t == touch) { touch = another; } another = null; lastPos.set( touch.current ); } }
Example #4
Source File: AboutScene.java From remixed-dungeon with GNU General Public License v3.0 | 6 votes |
private Text createTouchEmail(final String address, Text text2) { Text text = createText(address, text2); text.hardlight( Window.TITLE_COLOR ); TouchArea area = new TouchArea( text ) { @Override protected void onClick( Touch touch ) { Intent intent = new Intent( Intent.ACTION_SEND); intent.setType("message/rfc822"); intent.putExtra(Intent.EXTRA_EMAIL, new String[]{address} ); intent.putExtra(Intent.EXTRA_SUBJECT, Game.getVar(R.string.app_name) ); Game.instance().startActivity( Intent.createChooser(intent, Game.getVar(R.string.AboutScene_Snd)) ); } }; add(area); return text; }
Example #5
Source File: WndStory.java From pixel-dungeon with GNU General Public License v3.0 | 6 votes |
public WndStory( String text ) { super( 0, 0, Chrome.get( Chrome.Type.SCROLL ) ); tf = PixelScene.createMultiline( text, 7 ); tf.maxWidth = WIDTH - MARGIN * 2; tf.measure(); tf.ra = bgR; tf.ga = bgG; tf.ba = bgB; tf.rm = -bgR; tf.gm = -bgG; tf.bm = -bgB; tf.x = MARGIN; add( tf ); add( new TouchArea( chrome ) { @Override protected void onClick( Touch touch ) { hide(); } } ); resize( (int)(tf.width() + MARGIN * 2), (int)Math.min( tf.height(), 180 ) ); }
Example #6
Source File: CellSelector.java From pixel-dungeon with GNU General Public License v3.0 | 6 votes |
@Override protected void onTouchUp( Touch t ) { if (pinching && (t == touch || t == another)) { pinching = false; int zoom = Math.round( camera.zoom ); camera.zoom( zoom ); PixelDungeon.zoom( (int)(zoom - PixelScene.defaultZoom) ); dragging = true; if (t == touch) { touch = another; } another = null; lastPos.set( touch.current ); } }
Example #7
Source File: CellSelector.java From pixel-dungeon with GNU General Public License v3.0 | 6 votes |
@Override protected void onTouchDown( Touch t ) { if (t != touch && another == null) { if (!touch.down) { touch = t; onTouchDown( t ); return; } pinching = true; another = t; startSpan = PointF.distance( touch.current, another.current ); startZoom = camera.zoom; dragging = false; } }
Example #8
Source File: WndStory.java From unleashed-pixel-dungeon with GNU General Public License v3.0 | 6 votes |
public WndStory( String text ) { super( 0, 0, Chrome.get( Chrome.Type.SCROLL ) ); tf = PixelScene.createMultiline( text, 7 ); tf.maxWidth = ShatteredPixelDungeon.landscape() ? WIDTH_L - MARGIN * 2: WIDTH_P - MARGIN *2; tf.measure(); tf.ra = bgR; tf.ga = bgG; tf.ba = bgB; tf.rm = -bgR; tf.gm = -bgG; tf.bm = -bgB; tf.x = MARGIN; add( tf ); add( new TouchArea( chrome ) { @Override protected void onClick( Touch touch ) { hide(); } } ); resize( (int)(tf.width() + MARGIN * 2), (int)Math.min( tf.height(), 180 ) ); }
Example #9
Source File: CellSelector.java From unleashed-pixel-dungeon with GNU General Public License v3.0 | 6 votes |
@Override protected void onTouchUp( Touch t ) { if (pinching && (t == touch || t == another)) { pinching = false; int zoom = Math.round( camera.zoom ); camera.zoom( zoom ); ShatteredPixelDungeon.zoom((int) (zoom - PixelScene.defaultZoom)); dragging = true; if (t == touch) { touch = another; } another = null; lastPos.set( touch.current ); } }
Example #10
Source File: CellSelector.java From unleashed-pixel-dungeon with GNU General Public License v3.0 | 6 votes |
@Override protected void onTouchDown( Touch t ) { if (t != touch && another == null) { if (!touch.down) { touch = t; onTouchDown( t ); return; } pinching = true; another = t; startSpan = PointF.distance( touch.current, another.current ); startZoom = camera.zoom; dragging = false; } else if (t != touch) { reset(); } }
Example #11
Source File: CellSelector.java From YetAnotherPixelDungeon with GNU General Public License v3.0 | 6 votes |
@Override protected void onTouchUp( Touch t ) { if (pinching && (t == touch || t == another)) { pinching = false; int zoom = Math.round( camera.zoom ); camera.zoom( zoom ); YetAnotherPixelDungeon.zoom((int) (zoom - PixelScene.defaultZoom)); dragging = true; if (t == touch) { touch = another; } another = null; lastPos.set( touch.current ); } }
Example #12
Source File: WndStory.java From YetAnotherPixelDungeon with GNU General Public License v3.0 | 6 votes |
public WndStory( String text ) { super( 0, 0, Chrome.get( Chrome.Type.SCROLL ) ); tf = PixelScene.createMultiline( text, 7 ); tf.maxWidth = WIDTH - MARGIN * 2; tf.measure(); tf.ra = bgR; tf.ga = bgG; tf.ba = bgB; tf.rm = -bgR; tf.gm = -bgG; tf.bm = -bgB; tf.x = MARGIN; add( tf ); add( new TouchArea( chrome ) { @Override protected void onClick( Touch touch ) { hide(); } } ); resize( (int)(tf.width() + MARGIN * 2), (int)Math.min( tf.height(), 180 ) ); }
Example #13
Source File: ScrollPane.java From YetAnotherPixelDungeon with GNU General Public License v3.0 | 5 votes |
@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 ); } }
Example #14
Source File: CellSelector.java From remixed-dungeon with GNU General Public License v3.0 | 5 votes |
@Override protected void onClick( Touch touch ) { if (dragging) { dragging = false; } else { select( ((DungeonTilemap)target).screenToTile( (int)touch.current.x, (int)touch.current.y ) ); } }
Example #15
Source File: CellSelector.java From remixed-dungeon with GNU General Public License v3.0 | 5 votes |
@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 ); } } }
Example #16
Source File: CellSelector.java From YetAnotherPixelDungeon with GNU General Public License v3.0 | 5 votes |
@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 ); } } }
Example #17
Source File: AboutScene.java From remixed-dungeon with GNU General Public License v3.0 | 5 votes |
private Text createTouchLink(final String address, Text visit) { Text text = createText(address, visit); text.hardlight( Window.TITLE_COLOR ); TouchArea area = new TouchArea( text ) { @Override protected void onClick( Touch touch ) { Game.instance().openUrl(Game.getVar(R.string.AboutScene_OurSite), address); } }; add(area); return text; }
Example #18
Source File: ScrollPane.java From pixel-dungeon with GNU General Public License v3.0 | 5 votes |
@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; } }
Example #19
Source File: ScrollPane.java From pixel-dungeon with GNU General Public License v3.0 | 5 votes |
@Override protected void onClick( Touch touch ) { if (dragging) { dragging = false; thumb.am = THUMB_ALPHA; } else { PointF p = content.camera.screenToCamera( (int)touch.current.x, (int)touch.current.y ); ScrollPane.this.onClick( p.x, p.y ); } }
Example #20
Source File: CellSelector.java From pixel-dungeon with GNU General Public License v3.0 | 5 votes |
@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 ); } } }
Example #21
Source File: ScrollPane.java From YetAnotherPixelDungeon with GNU General Public License v3.0 | 5 votes |
@Override protected void onClick( Touch touch ) { if (dragging) { dragging = false; indicator.am = INDICATOR_ALPHA; } else { PointF p = content.camera.screenToCamera( (int)touch.current.x, (int)touch.current.y ); ScrollPane.this.onClick( p.x, p.y ); } }
Example #22
Source File: CellSelector.java From pixel-dungeon with GNU General Public License v3.0 | 5 votes |
@Override protected void onClick( Touch touch ) { if (dragging) { dragging = false; } else { select( ((DungeonTilemap)target).screenToTile( (int)touch.current.x, (int)touch.current.y ) ); } }
Example #23
Source File: ScrollPane.java From remixed-dungeon with GNU General Public License v3.0 | 5 votes |
@Override protected void onClick( Touch touch ) { if (dragging) { dragging = false; } else { PointF p = content.camera.screenToCamera( (int)touch.current.x, (int)touch.current.y ); ScrollPane.this.onClick( p.x, p.y ); } }
Example #24
Source File: ScrollPane.java From unleashed-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
@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; } lastPos.set( t.current ); } else if (PointF.distance( t.current, t.start ) > dragThreshold) { dragging = true; lastPos.set( t.current ); } }
Example #25
Source File: ScrollPane.java From remixed-dungeon with GNU General Public License v3.0 | 5 votes |
@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; } lastPos.set( t.current ); } else if (PointF.distance( t.current, t.start ) > dragThreshold) { dragging = true; lastPos.set( t.current ); } }
Example #26
Source File: CellSelector.java From YetAnotherPixelDungeon with GNU General Public License v3.0 | 5 votes |
@Override protected void onClick( Touch touch ) { if (dragging) { dragging = false; } else { select( ((DungeonTilemap)target).screenToTile( (int)touch.current.x, (int)touch.current.y ) ); } }
Example #27
Source File: CellSelector.java From unleashed-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
@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 ); } } }
Example #28
Source File: CellSelector.java From unleashed-pixel-dungeon with GNU General Public License v3.0 | 5 votes |
@Override protected void onClick( Touch touch ) { if (dragging) { dragging = false; } else { select( ((DungeonTilemap)target).screenToTile( (int)touch.current.x, (int)touch.current.y ) ); } }
Example #29
Source File: TouchArea.java From PD-classes with GNU General Public License v3.0 | 4 votes |
protected void onTouchDown( Touch touch ) { }
Example #30
Source File: AboutScene.java From remixed-dungeon with GNU General Public License v3.0 | 4 votes |
@Override public void create() { super.create(); Text text = createText(getTXT(), null ); text.camera = uiCamera; text.x = align( (Camera.main.width - text.width()) / 2 ); text.y = align( (Camera.main.height - text.height()) / 3 ); Text email = createTouchEmail(Game.getVar(R.string.AboutScene_Mail), text); Text visit = createText(Game.getVar(R.string.AboutScene_OurSite), email); Text site = createTouchLink(Game.getVar(R.string.AboutScene_Lnk), visit); createText("\n"+ getTRN(), site); Image nyrdie = Icons.NYRDIE.get(); nyrdie.x = align( text.x + (text.width() - nyrdie.width) / 2 ); nyrdie.y = text.y - nyrdie.height - 8; add( nyrdie ); TouchArea area = new TouchArea( nyrdie ) { private int clickCounter = 0; @Override protected void onClick( Touch touch ) { clickCounter++; if(clickCounter > 11) { return; } if(clickCounter>10) { Game.toast("Levels test mode enabled"); Scene.setMode("levelsTest"); return; } if(clickCounter>7) { Game.toast("Are you sure?"); return; } if(clickCounter>3) { Game.toast("%d", clickCounter); } } }; add(area); new Flare( 7, 64 ).color( 0x332211, true ).show( nyrdie, 0 ).angularSpeed = -20; Archs archs = new Archs(); archs.setSize( Camera.main.width, Camera.main.height ); addToBack( archs ); ExitButton btnExit = new ExitButton(); btnExit.setPos( Camera.main.width - btnExit.width(), 0 ); add( btnExit ); fadeIn(); }