com.watabou.noosa.TouchArea Java Examples
The following examples show how to use
com.watabou.noosa.TouchArea.
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: 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 #2
Source File: UpdateNotification.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 6 votes |
@Override protected void createChildren() { panel = Chrome.get(Chrome.Type.GREY_BUTTON_TR); add( panel ); //updateMessage = new BitmapText("Checking Updates", PixelScene.font1x); updateMessage = PixelScene.renderTextBlock("Checking Updates", 9); add(updateMessage); touchUpdate = new TouchArea( panel ){ @Override protected void onClick( NoosaInputProcessor.Touch touch ) { if (updateAvailable) { parent.add(new WndUpdate() ); Sample.INSTANCE.play( Assets.SND_CLICK ); } } }; add(touchUpdate); updateMessage(); }
Example #3
Source File: WndStory.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 6 votes |
public WndStory( String text ) { super( 0, 0, Chrome.get( Chrome.Type.SCROLL ) ); tf = PixelScene.renderTextBlock( text, 6 ); tf.maxWidth(SPDSettings.landscape() ? WIDTH_L - MARGIN * 2: WIDTH_P - MARGIN *2); tf.invert(); tf.setPos(MARGIN, 2); add( tf ); add( new TouchArea( chrome ) { @Override protected void onClick( NoosaInputProcessor.Touch touch ) { hide(); } } ); resize( (int)(tf.width() + MARGIN * 2), (int)Math.min( tf.height()+2, 180 ) ); }
Example #4
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 #5
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 #6
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 #7
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 #8
Source File: ChangesWindow.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 5 votes |
public ChangesWindow(Image icon, String title, String message ) { super( icon, title, message); TouchArea blocker = new TouchArea( 0, 0, PixelScene.uiCamera.width, PixelScene.uiCamera.height ) { @Override protected void onClick( NoosaInputProcessor.Touch touch ) { hide(); } }; blocker.camera = PixelScene.uiCamera; add(blocker); }
Example #9
Source File: Button.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 5 votes |
@Override protected void createChildren() { hotArea = new TouchArea<T>( 0, 0, 0, 0 ) { @Override protected void onTouchDown(NoosaInputProcessor.Touch touch) { pressed = true; pressTime = 0; processed = false; Button.this.onTouchDown(); }; @Override protected void onTouchUp(NoosaInputProcessor.Touch touch) { pressed = false; Button.this.onTouchUp(); }; @Override protected void onClick( NoosaInputProcessor.Touch touch ) { if (!processed) { if (NoosaInputProcessor.modifier && onLongClick()) { // Do nothing } else { Button.this.onClick(); } } }; @Override public boolean onKeyDown(NoosaInputProcessor.Key<T> key) { return Button.this.onKeyDown(key); } @Override public boolean onKeyUp(NoosaInputProcessor.Key<T> key) { return Button.this.onKeyUp(key); } }; add( hotArea ); }
Example #10
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(); }
Example #11
Source File: WndSelectLanguage.java From remixed-dungeon with GNU General Public License v3.0 | 4 votes |
public WndSelectLanguage(String title, String... options) { super(); int WIDTH = WndHelper.getFullscreenWidth(); int maxW = WIDTH - GAP * 2; Text tfTitle = PixelScene.createMultiline(title, GuiProperties.titleFontSize()); tfTitle.hardlight(TITLE_COLOR); tfTitle.x = tfTitle.y = GAP; tfTitle.maxWidth(maxW); add(tfTitle); Text pleaseHelpTranslate = PixelScene.createMultiline(Game.getVar(R.string.WndSelectLanguage_ImproveTranslation), GuiProperties.titleFontSize()); pleaseHelpTranslate.maxWidth(maxW); pleaseHelpTranslate.x = GAP; pleaseHelpTranslate.y = tfTitle.y + tfTitle.height() + GAP; add(pleaseHelpTranslate); Text translateLink = PixelScene.createMultiline(Game.getVar(R.string.WndSelectLanguage_LinkToTranslationSite), GuiProperties.titleFontSize()); translateLink.hardlight(TITLE_COLOR); translateLink.maxWidth(maxW); translateLink.x = GAP; translateLink.y = pleaseHelpTranslate.y + pleaseHelpTranslate.height() + GAP; add(translateLink); TouchArea area = new TouchArea(translateLink) { @Override protected void onClick(Touchscreen.Touch touch) { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(Game.getVar(R.string.WndSelectLanguage_TranslationLink))); Game.instance().startActivity(Intent.createChooser(intent, Game.getVar(R.string.WndSelectLanguage_TranslationLink))); } }; add(area); float pos = translateLink.y + translateLink.height() + GAP; final int columns = RemixedDungeon.landscape() ? 3 : 2; int BUTTON_WIDTH = WIDTH / columns - GAP; int lastButtonBottom = 0; for (int i = 0; i < options.length / columns + 1; i++) { for (int j = 0; j < columns; j++) { final int index = i * columns + j; if (!(index < options.length)) { break; } SystemRedButton btn = new SystemRedButton(options[index]) { @Override protected void onClick() { hide(); onSelect(index); } }; btn.setRect(GAP + j * (BUTTON_WIDTH + GAP), pos, BUTTON_WIDTH, BUTTON_HEIGHT); add(btn); lastButtonBottom = (int) btn.bottom(); } pos += BUTTON_HEIGHT + GAP; } resize(WIDTH, lastButtonBottom + GAP); }
Example #12
Source File: StatusPane.java From remixed-dungeon with GNU General Public License v3.0 | 4 votes |
@Override protected void createChildren() { shield = new NinePatch(Assets.getStatus(), 80, 0, 30 + 18, 0); add(shield); add(new TouchArea(0, 1, 30, 30) { @Override protected void onClick(Touch touch) { Image sprite = hero.getSprite(); if (!sprite.isVisible()) { Camera.main.focusOn(sprite); } GameScene.show(new WndHero()); } }); avatar = hero.getSprite().avatar(); add(avatar); blood = new Emitter(); blood.pos(avatar); blood.pour(BloodParticle.FACTORY, 0.3f); blood.autoKill = false; blood.on = false; add(blood); int compassTarget = currentLevel.entrance; if (currentLevel.hasCompassTarget()) { compassTarget = currentLevel.getCompassTarget(); // Set to compass target if exists } else if ( currentLevel.hasExit(0) && hero.getBelongings().getItem(Amulet.class) == null) { compassTarget = currentLevel.getExit(0); // Set to first exit if exists } compass = new Compass(compassTarget, currentLevel); add(compass); hp = new Image(Assets.HP_BAR); add(hp); sp = new Image(Assets.SP_BAR); add(sp); exp = new Image(Assets.XP_BAR); add(exp); level = new BitmapText(PixelScene.font1x); level.hardlight(0xFFEBA4); add(level); depth = new BitmapText(Integer.toString(Dungeon.depth), PixelScene.font1x); depth.hardlight(0xCACFC2); add(depth); hero.getBelongings().countIronKeys(); keys = new BitmapText(PixelScene.font1x); keys.hardlight(0xCACFC2); add(keys); danger = new DangerIndicator(); add(danger); loot = new LootIndicator(); add(loot); buffs = new BuffIndicator(hero); add(buffs); btnMenu = new MenuButton(new Image(Assets.getStatus(), 114, 3, 12, 11), WndGame.class); add(btnMenu); btnHats = new MenuButton(new Image(Assets.getStatus(), 114, 18, 12, 11), WndHats.class); if (!Flavours.haveHats()) { btnHats.enable(false); } add(btnHats); }
Example #13
Source File: StatusPane.java From pixel-dungeon with GNU General Public License v3.0 | 4 votes |
@Override protected void createChildren() { shield = new NinePatch( Assets.STATUS, 80, 0, 30 + 18, 0 ); add( shield ); add( new TouchArea( 0, 1, 30, 30 ) { @Override protected void onClick( Touch touch ) { Image sprite = Dungeon.hero.sprite; if (!sprite.isVisible()) { Camera.main.focusOn( sprite ); } GameScene.show( new WndHero() ); }; } ); btnMenu = new MenuButton(); add( btnMenu ); avatar = HeroSprite.avatar( Dungeon.hero.heroClass, lastTier ); add( avatar ); blood = new BitmaskEmitter( avatar ); blood.pour( BloodParticle.FACTORY, 0.3f ); blood.autoKill = false; blood.on = false; add( blood ); compass = new Compass( Dungeon.level.exit ); add( compass ); hp = new Image( Assets.HP_BAR ); add( hp ); exp = new Image( Assets.XP_BAR ); add( exp ); level = new BitmapText( PixelScene.font1x ); level.hardlight( 0xFFEBA4 ); add( level ); depth = new BitmapText( Integer.toString( Dungeon.depth ), PixelScene.font1x ); depth.hardlight( 0xCACFC2 ); depth.measure(); add( depth ); Dungeon.hero.belongings.countIronKeys(); keys = new BitmapText( PixelScene.font1x ); keys.hardlight( 0xCACFC2 ); add( keys ); danger = new DangerIndicator(); add( danger ); loot = new LootIndicator(); add( loot ); resume = new ResumeButton(); add( resume ); buffs = new BuffIndicator( Dungeon.hero ); add( buffs ); }
Example #14
Source File: AboutScene.java From pixel-dungeon with GNU General Public License v3.0 | 4 votes |
@Override public void create() { super.create(); BitmapTextMultiline text = createMultiline( TXT, 8 ); text.maxWidth = Math.min( Camera.main.width, 120 ); text.measure(); add( text ); text.x = align( (Camera.main.width - text.width()) / 2 ); text.y = align( (Camera.main.height - text.height()) / 2 ); BitmapTextMultiline link = createMultiline( LNK, 8 ); link.maxWidth = Math.min( Camera.main.width, 120 ); link.measure(); link.hardlight( Window.TITLE_COLOR ); add( link ); link.x = text.x; link.y = text.y + text.height(); TouchArea hotArea = new TouchArea( link ) { @Override protected void onClick( Touch touch ) { Intent intent = new Intent( Intent.ACTION_VIEW, Uri.parse( "http://" + LNK ) ); Game.instance.startActivity( intent ); } }; add( hotArea ); Image wata = Icons.WATA.get(); wata.x = align( (Camera.main.width - wata.width) / 2 ); wata.y = text.y - wata.height - 8; add( wata ); new Flare( 7, 64 ).color( 0x112233, true ).show( wata, 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(); }
Example #15
Source File: StatusPane.java From unleashed-pixel-dungeon with GNU General Public License v3.0 | 4 votes |
@Override protected void createChildren() { shield = new NinePatch( Assets.STATUS, 80, 0, 30 + 18, 0 ); add( shield ); add( new TouchArea( 0, 1, 31, 31 ) { @Override protected void onClick( Touch touch ) { Image sprite = Dungeon.hero.sprite; if (!sprite.isVisible()) { Camera.main.focusOn( sprite ); } GameScene.show( new WndHero() ); } } ); btnMenu = new MenuButton(); add( btnMenu ); avatar = HeroSprite.avatar( Dungeon.hero.heroClass, lastTier ); add( avatar ); blood = new Emitter(); blood.pos( avatar ); blood.pour( BloodParticle.FACTORY, 0.3f ); blood.autoKill = false; blood.on = false; add( blood ); compass = new Compass( Dungeon.level.exit ); add( compass ); hp = new Image( Assets.HP_BAR ); add( hp ); exp = new Image( Assets.XP_BAR ); add( exp ); level = new BitmapText( PixelScene.font1x ); level.hardlight( 0xFFEBA4 ); add( level ); depth = new BitmapText( Integer.toString( Dungeon.depth ), PixelScene.font1x ); depth.hardlight( 0xCACFC2 ); depth.measure(); add( depth ); Dungeon.hero.belongings.countIronKeys(); keys = new BitmapText( PixelScene.font1x ); keys.hardlight( 0xCACFC2 ); add( keys ); danger = new DangerIndicator(); add( danger ); buffs = new BuffIndicator( Dungeon.hero ); add( buffs ); }
Example #16
Source File: StatusPane.java From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 | 4 votes |
@Override protected void createChildren() { bg = new NinePatch( Assets.STATUS, 0, 0, 128, 36, 85, 0, 45, 0 ); add( bg ); add( new TouchArea<GameAction>( 0, 1, 31, 31 ) { @Override protected void onClick( NoosaInputProcessor.Touch touch ) { Image sprite = Dungeon.hero.sprite; Camera.main.panTo( sprite.center(), 5f ); GameScene.show( new WndHero() ); } @Override public boolean onKeyUp(NoosaInputProcessor.Key<GameAction> key) { boolean handled = true; switch (key.action) { case HERO_INFO: onClick( null ); break; case JOURNAL: GameScene.show( new WndJournal() ); break; default: handled = false; break; } return handled; } } ); btnJournal = new JournalButton(); add( btnJournal ); btnMenu = new MenuButton(); add( btnMenu ); avatar = HeroSprite.avatar( Dungeon.hero.heroClass, lastTier ); add( avatar ); compass = new Compass( Statistics.amuletObtained ? Dungeon.level.entrance : Dungeon.level.exit ); add( compass ); rawShielding = new Image( Assets.SHLD_BAR ); rawShielding.alpha(0.5f); add(rawShielding); shieldedHP = new Image( Assets.SHLD_BAR ); add(shieldedHP); hp = new Image( Assets.HP_BAR ); add( hp ); exp = new Image( Assets.XP_BAR ); add( exp ); bossHP = new BossHealthBar(); add( bossHP ); level = new BitmapText( PixelScene.pixelFont); level.hardlight( 0xFFEBA4 ); add( level ); depth = new BitmapText( Integer.toString( Dungeon.depth ), PixelScene.pixelFont); depth.hardlight( 0xCACFC2 ); depth.measure(); add( depth ); danger = new DangerIndicator(); add( danger ); buffs = new BuffIndicator( Dungeon.hero ); add( buffs ); add( pickedUp = new Toolbar.PickedUpItem()); version = new BitmapText( "v" + Game.version, PixelScene.pixelFont); version.alpha( 0.5f ); add(version); }
Example #17
Source File: StatusPane.java From YetAnotherPixelDungeon with GNU General Public License v3.0 | 4 votes |
@Override protected void createChildren() { shield = new NinePatch( Assets.STATUS, 80, 0, 48, 0 ); add( shield ); add( new TouchArea( 0, 1, 30, 30 ) { @Override protected void onClick( Touch touch ) { Image sprite = Dungeon.hero.sprite; if (!sprite.isVisible()) { Camera.main.focusOn( sprite ); } GameScene.show( new WndHero() ); }; } ); btnMenu = new MenuButton(); add( btnMenu ); difficulty = new IconDifficulty(); add(difficulty); avatar = HeroSprite.avatar( Dungeon.hero.heroClass, lastTier ); add(avatar); // blood = new Emitter(); // blood.pos(avatar); // blood.pour(BloodParticle.FACTORY, 0.3f); // blood.autoKill = false; // blood.on = false; // addFromDamage(blood); compass = new Compass( Dungeon.level.exit ); add( compass ); hp = new Image( Assets.HP_BAR ); add( hp ); exp = new Image( Assets.XP_BAR ); add(exp); level = new BitmapText( PixelScene.font1x ); level.hardlight(0xFFEBA4); add(level); health = new BitmapText( PixelScene.font1x ); health.hardlight(0xCACFC2); add(health); depth = new BitmapText( Integer.toString( Dungeon.depth ), PixelScene.font1x ); depth.hardlight(0xCACFC2); depth.measure(); add( depth ); Dungeon.hero.belongings.countIronKeys(); keys = new BitmapText( PixelScene.font1x ); keys.hardlight(0xCACFC2); add(keys); danger = new TagDanger(); add(danger); attack = new TagAttack(); add( attack ); pickup = new TagPickup(); add(pickup); resume = new TagResume(); add( resume ); btnWaterskin = new TagWaterskin(); add(btnWaterskin); btnOilLantern = new TagOilLantern(); add(btnOilLantern); buffs = new BuffIndicator( Dungeon.hero ); add( buffs ); }