com.watabou.noosa.tweeners.AlphaTweener Java Examples

The following examples show how to use com.watabou.noosa.tweeners.AlphaTweener. 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: DungeonTilemap.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 6 votes vote down vote up
public void discover( int pos, int oldValue ) {
	
	int visual = getTileVisual( pos, oldValue, false);
	if (visual < 0) return;
	
	final Image tile = new Image( texture );
	tile.frame( tileset.get( getTileVisual( pos, oldValue, false)));
	tile.point( tileToWorld( pos ) );

	parent.add( tile );
	
	parent.add( new AlphaTweener( tile, 0, 0.6f ) {
		protected void onComplete() {
			tile.killAndErase();
			killAndErase();
		}
	} );
}
 
Example #2
Source File: Wraith.java    From remixed-dungeon with GNU General Public License v3.0 6 votes vote down vote up
public static Wraith spawnAt( int pos ) {
	if (Dungeon.level.passable[pos] && Actor.findChar( pos ) == null) {
		
		Wraith w = new Wraith();
		w.setPos(pos);
		w.setState(MobAi.getStateByClass(Hunting.class));
		Dungeon.level.spawnMob(w, SPAWN_DELAY );
		
		w.getSprite().alpha( 0 );
		w.getSprite().getParent().add( new AlphaTweener( w.getSprite(), 1, 0.5f ) );
		
		w.getSprite().emitter().burst( ShadowParticle.CURSE, 5 );
		
		return w;
	} else {
		return null;
	}
}
 
Example #3
Source File: Wraith.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 6 votes vote down vote up
public static Wraith spawnAt( int pos ) {
	if (Dungeon.level.passable[pos] && Actor.findChar( pos ) == null) {
		
		Wraith w = new Wraith();
		w.adjustStats( Dungeon.depth );
		w.pos = pos;
		w.state = w.HUNTING;
		GameScene.add( w, SPAWN_DELAY );
		
		w.sprite.alpha( 0 );
		w.sprite.parent.add( new AlphaTweener( w.sprite, 1, 0.5f ) );
		
		w.sprite.emitter().burst( ShadowParticle.CURSE, 5 );
		
		return w;
	} else {
		return null;
	}
}
 
Example #4
Source File: WandOfBlink.java    From remixed-dungeon with GNU General Public License v3.0 6 votes vote down vote up
public static void appear(@NotNull Char ch, int pos ) {

		Level level = Dungeon.level;

		if(level.cellValid(ch.getPos())) { //ch already on level
			ch.getSprite().interruptMotion();
			ch.placeTo(pos);
		} else { // brand new ch
			ch.setPos(pos);
			if(ch instanceof Mob) {
				level.spawnMob((Mob)ch);
			}
		}

		ch.getSprite().place( pos );

		if (ch.invisible == 0) {
			ch.getSprite().alpha( 0 );
			ch.getSprite().getParent().add( new AlphaTweener( ch.getSprite(), 1, 0.4f ) );
		}

		ch.getSprite().emitter().start( Speck.factory( Speck.LIGHT ), 0.2f, 3 );
		Sample.INSTANCE.play( Assets.SND_TELEPORT );
	}
 
Example #5
Source File: DungeonTilemap.java    From remixed-dungeon with GNU General Public License v3.0 6 votes vote down vote up
public void discover(int pos) {

		final Image tile = tile(pos);

		if(tile==null) {
			return;
		}

		tile.point(tileToWorld(pos));

		// For bright mode
		tile.rm = tile.gm = tile.bm = rm;
		tile.ra = tile.ga = tile.ba = ra;
		getParent().add(tile);

		getParent().add(new AlphaTweener(tile, 0, 0.6f) {
			protected void onComplete() {
				tile.killAndErase();
				killAndErase();
			}
		});

	}
 
Example #6
Source File: Wraith.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 6 votes vote down vote up
public static Wraith spawnAt( int depth, int pos ) {

        if (!Level.solid[pos] && Actor.findChar( pos ) == null) {

            Wraith w = new Wraith( depth );

            w.pos = pos;
            w.special = true;
            w.enemySeen = true;
            w.state = w.HUNTING;

            GameScene.add( w, SPAWN_DELAY );

            w.sprite.alpha( 0 );
            w.sprite.parent.add( new AlphaTweener( w.sprite, 1, 0.5f ) );

            w.sprite.emitter().burst( ShadowParticle.CURSE, 5 );

            return w;
        } else {
            return null;
        }
    }
 
Example #7
Source File: DungeonTilemap.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 6 votes vote down vote up
public void discover( int pos, int oldValue ) {
	
	final Image tile = tile( oldValue );
	tile.point( tileToWorld( pos ) );
	
	// For bright mode
	tile.rm = tile.gm = tile.bm = rm;
	tile.ra = tile.ga = tile.ba = ra;
	parent.add( tile );
	
	parent.add( new AlphaTweener( tile, 0, 0.6f ) {
		protected void onComplete() {
			tile.killAndErase();
			killAndErase();
		};
	} );
}
 
Example #8
Source File: DungeonTilemap.java    From shattered-pixel-dungeon with GNU General Public License v3.0 6 votes vote down vote up
public void discover( int pos, int oldValue ) {
	
	int visual = getTileVisual( pos, oldValue, false);
	if (visual < 0) return;
	
	final Image tile = new Image( texture );
	tile.frame( tileset.get( getTileVisual( pos, oldValue, false)));
	tile.point( tileToWorld( pos ) );

	parent.add( tile );
	
	parent.add( new AlphaTweener( tile, 0, 0.6f ) {
		protected void onComplete() {
			tile.killAndErase();
			killAndErase();
		}
	} );
}
 
Example #9
Source File: ScrollOfTeleportation.java    From shattered-pixel-dungeon with GNU General Public License v3.0 6 votes vote down vote up
public static void appear( Char ch, int pos ) {

		ch.sprite.interruptMotion();

		if (Dungeon.level.heroFOV[pos] || Dungeon.level.heroFOV[ch.pos]){
			Sample.INSTANCE.play(Assets.Sounds.TELEPORT);
		}

		ch.move( pos );
		if (ch.pos == pos) ch.sprite.place( pos );

		if (ch.invisible == 0) {
			ch.sprite.alpha( 0 );
			ch.sprite.parent.add( new AlphaTweener( ch.sprite, 1, 0.4f ) );
		}

		if (Dungeon.level.heroFOV[pos] || ch == Dungeon.hero ) {
			ch.sprite.emitter().start(Speck.factory(Speck.LIGHT), 0.2f, 3);
		}
	}
 
Example #10
Source File: Wraith.java    From unleashed-pixel-dungeon with GNU General Public License v3.0 6 votes vote down vote up
public static Wraith spawnAt( int pos ) {
	if (Level.passable[pos] && Actor.findChar( pos ) == null) {
		
		Wraith w = new Wraith();
		w.adjustStats( Dungeon.depth );
		w.pos = pos;
		w.state = w.HUNTING;
		GameScene.add( w, SPAWN_DELAY );
		
		w.sprite.alpha( 0 );
		w.sprite.parent.add( new AlphaTweener( w.sprite, 1, 0.5f ) );
		
		w.sprite.emitter().burst( ShadowParticle.CURSE, 5 );
		
		return w;
	} else {
		return null;
	}
}
 
Example #11
Source File: DungeonTilemap.java    From unleashed-pixel-dungeon with GNU General Public License v3.0 6 votes vote down vote up
public void discover( int pos, int oldValue ) {
	
	final Image tile = tile( oldValue );
	tile.point( tileToWorld( pos ) );

	// For bright mode
	tile.rm = tile.gm = tile.bm = rm;
	tile.ra = tile.ga = tile.ba = ra;
	parent.add( tile );
	
	parent.add( new AlphaTweener( tile, 0, 0.6f ) {
		protected void onComplete() {
			tile.killAndErase();
			killAndErase();
		}
	} );
}
 
Example #12
Source File: Wraith.java    From shattered-pixel-dungeon with GNU General Public License v3.0 6 votes vote down vote up
public static Wraith spawnAt( int pos ) {
	if (Dungeon.level.passable[pos] && Actor.findChar( pos ) == null) {
		
		Wraith w = new Wraith();
		w.adjustStats( Dungeon.depth );
		w.pos = pos;
		w.state = w.HUNTING;
		GameScene.add( w, SPAWN_DELAY );
		
		w.sprite.alpha( 0 );
		w.sprite.parent.add( new AlphaTweener( w.sprite, 1, 0.5f ) );
		
		w.sprite.emitter().burst( ShadowParticle.CURSE, 5 );
		
		return w;
	} else {
		return null;
	}
}
 
Example #13
Source File: Ghost.java    From pixel-dungeon with GNU General Public License v3.0 6 votes vote down vote up
public static void replace( final Mob a, final Mob b ) {
	final float FADE_TIME = 0.5f;
	
	a.destroy();
	a.sprite.parent.add( new AlphaTweener( a.sprite, 0, FADE_TIME ) {
		protected void onComplete() {
			a.sprite.killAndErase();
			parent.erase( this );
		};
	} );
	
	b.pos = a.pos;
	GameScene.add( b );
	
	b.sprite.flipHorizontal = a.sprite.flipHorizontal;
	b.sprite.alpha( 0 );
	b.sprite.parent.add( new AlphaTweener( b.sprite, 1, FADE_TIME ) );
}
 
Example #14
Source File: Wraith.java    From pixel-dungeon with GNU General Public License v3.0 6 votes vote down vote up
public static Wraith spawnAt( int pos ) {
	if (Level.passable[pos] && Actor.findChar( pos ) == null) {
		
		Wraith w = new Wraith();
		w.adjustStats( Dungeon.depth );
		w.pos = pos;
		w.state = w.HUNTING;
		GameScene.add( w, SPAWN_DELAY );
		
		w.sprite.alpha( 0 );
		w.sprite.parent.add( new AlphaTweener( w.sprite, 1, 0.5f ) );
		
		w.sprite.emitter().burst( ShadowParticle.CURSE, 5 );
		
		return w;
	} else {
		return null;
	}
}
 
Example #15
Source File: DungeonTilemap.java    From pixel-dungeon with GNU General Public License v3.0 6 votes vote down vote up
public void discover( int pos, int oldValue ) {
	
	final Image tile = tile( oldValue );
	tile.point( tileToWorld( pos ) );
	
	// For bright mode
	tile.rm = tile.gm = tile.bm = rm;
	tile.ra = tile.ga = tile.ba = ra;
	parent.add( tile );
	
	parent.add( new AlphaTweener( tile, 0, 0.6f ) {
		protected void onComplete() {
			tile.killAndErase();
			killAndErase();
		};
	} );
}
 
Example #16
Source File: NewCityBossLevel.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void seal() {
	super.seal();

	for (Mob m : mobs){
		//bring the first ally with you
		if (m.alignment == Char.Alignment.ALLY && !m.properties().contains(Char.Property.IMMOVABLE)){
			m.pos = Dungeon.hero.pos + (Random.Int(2) == 0 ? +1 : -1);
			m.sprite.place(m.pos);
			break;
		}
	}

	DwarfKing boss = new DwarfKing();
	boss.state = boss.WANDERING;
	boss.pos = pointToCell(arena.center());
	GameScene.add( boss );

	if (heroFOV[boss.pos]) {
		boss.notice();
		boss.sprite.alpha( 0 );
		boss.sprite.parent.add( new AlphaTweener( boss.sprite, 1, 0.1f ) );
	}

	set( bottomDoor, Terrain.LOCKED_DOOR );
	GameScene.updateMap( bottomDoor );
	Dungeon.observe();
}
 
Example #17
Source File: WardSprite.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void die() {
	super.die();
	//cancels die animation and fades out immediately
	play(idle, true);
	emitter().burst(MagicMissile.WardParticle.UP, 10);
	parent.add( new AlphaTweener( this, 0, 2f ) {
		@Override
		protected void onComplete() {
			WardSprite.this.killAndErase();
			parent.erase( this );
		}
	} );
}
 
Example #18
Source File: ShadowLord.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
private void twistLevel() {

		if(!isAlive()) {
			return;
		}

		Level level = Dungeon.level;

		if(!levelCreated)
		{
			Tools.makeEmptyLevel(level, false);
			Tools.buildShadowLordMaze(level, 6);
			levelCreated = true;
		}

		int cell = level.getRandomTerrainCell(Terrain.PEDESTAL);
		if (level.cellValid(cell)) {
			if (Actor.findChar(cell) == null) {
				Mob mob = Crystal.makeShadowLordCrystal();
				mob.setPos(cell);
				level.spawnMob(mob);

				mob.getSprite().alpha( 0 );
				mob.getSprite().getParent().add( new AlphaTweener( mob.getSprite(), 1, 0.4f ) );

				mob.getSprite().emitter().start( Speck.factory( Speck.LIGHT ), 0.2f, 3 );
				Sample.INSTANCE.play( Assets.SND_TELEPORT );

				int x, y;
				x = level.cellX(cell);
				y = level.cellY(cell);

				level.fillAreaWith(Darkness.class, x - 2, y - 2, 5, 5, 1);
			} else {
				damage(ht() / 9, this);
			}
		}
	}
 
Example #19
Source File: MobSprite.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onComplete( Animation anim ) {
	
	super.onComplete( anim );
	
	if (anim == die) {
		getParent().add( new AlphaTweener( this, 0, FADE_TIME ) {
			@Override
			protected void onComplete() {
				MobSprite.this.killAndErase();
			}
		} );
	}
}
 
Example #20
Source File: CharSprite.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public void add(State state) {
    ch.ifPresent(chr -> {
        switch (state) {
            case BURNING:
                burning = emitter();
                burning.pour(FlameParticle.FACTORY, 0.06f);
                if (getVisible()) {
                    Sample.INSTANCE.play(Assets.SND_BURNING);
                }
                break;
            case LEVITATING:
                levitation = emitter();
                levitation.pour(Speck.factory(Speck.JET), 0.02f);
                break;
            case INVISIBLE:
                float alpha = chr instanceof Hero ? INVISIBILITY_ALPHA : 0.0f;

                if (hasParent()) {
                    getParent().add(new AlphaTweener(this, alpha, 0.4f));
                } else {
                    alpha(alpha);
                }
                break;
            case PARALYSED:
                paused = true;
                break;
            case FROZEN:
                iceBlock = IceBlock.freeze(this);
                paused = true;
                break;
            case ILLUMINATED:
                GameScene.effect(halo = new TorchHalo(this));
                break;
        }
    });
}
 
Example #21
Source File: CloakOfShadows.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void execute( Hero hero, String action ) {

	super.execute(hero, action);

	if (action.equals( AC_STEALTH )) {

		if (!stealthed){
			if (!isEquipped(hero)) GLog.i( Messages.get(Artifact.class, "need_to_equip") );
			else if (cursed)       GLog.i( Messages.get(this, "cursed") );
			else if (charge <= 0)  GLog.i( Messages.get(this, "no_charge") );
			else {
				stealthed = true;
				hero.spend( 1f );
				hero.busy();
				Sample.INSTANCE.play(Assets.Sounds.MELD);
				activeBuff = activeBuff();
				activeBuff.attachTo(hero);
				if (hero.sprite.parent != null) {
					hero.sprite.parent.add(new AlphaTweener(hero.sprite, 0.4f, 0.4f));
				} else {
					hero.sprite.alpha(0.4f);
				}
				hero.sprite.operate(hero.pos);
			}
		} else {
			stealthed = false;
			activeBuff.detach();
			activeBuff = null;
			hero.spend( 1f );
			hero.sprite.operate( hero.pos );
		}

	}
}
 
Example #22
Source File: WardSprite.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void die() {
	super.die();
	//cancels die animation and fades out immediately
	play(idle, true);
	emitter().burst(MagicMissile.WardParticle.UP, 10);
	parent.add( new AlphaTweener( this, 0, 2f ) {
		@Override
		protected void onComplete() {
			WardSprite.this.killAndErase();
			parent.erase( this );
		}
	} );
}
 
Example #23
Source File: MobSprite.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onComplete( Animation anim ) {
	
	super.onComplete( anim );
	
	if (anim == die) {
		parent.add( new AlphaTweener( this, 0, FADE_TIME ) {
			@Override
			protected void onComplete() {
				MobSprite.this.killAndErase();
				parent.erase( this );
			}
		} );
	}
}
 
Example #24
Source File: WandOfBlink.java    From pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public static void appear( Char ch, int pos ) {
	
	ch.sprite.interruptMotion();
	
	ch.move( pos );
	ch.sprite.place( pos );
	
	if (ch.invisible == 0) {
		ch.sprite.alpha( 0 );
		ch.sprite.parent.add( new AlphaTweener( ch.sprite, 1, 0.4f ) );
	}
	
	ch.sprite.emitter().start( Speck.factory( Speck.LIGHT ), 0.2f, 3 );
	Sample.INSTANCE.play( Assets.SND_TELEPORT );
}
 
Example #25
Source File: PotionOfInvisibility.java    From pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public static void melt( Char ch ) {
	if (ch.sprite.parent != null) {
		ch.sprite.parent.add( new AlphaTweener( ch.sprite, ALPHA, 0.4f ) );
	} else {
		ch.sprite.alpha( ALPHA );
	}
}
 
Example #26
Source File: ScrollOfTeleportation.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 5 votes vote down vote up
public static void appear( Char ch, int pos ) {

		ch.sprite.interruptMotion();

		ch.move( pos );
		if (ch.pos == pos) ch.sprite.place( pos );

		if (ch.invisible == 0) {
			ch.sprite.alpha( 0 );
			ch.sprite.parent.add( new AlphaTweener( ch.sprite, 1, 0.4f ) );
		}

		ch.sprite.emitter().start( Speck.factory(Speck.LIGHT), 0.2f, 3 );
		Sample.INSTANCE.play( Assets.SND_TELEPORT );
	}
 
Example #27
Source File: CloakOfShadows.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void execute( Hero hero, String action ) {

	super.execute(hero, action);

	if (action.equals( AC_STEALTH )) {

		if (!stealthed){
			if (!isEquipped(hero)) GLog.i( Messages.get(Artifact.class, "need_to_equip") );
			else if (cursed)       GLog.i( Messages.get(this, "cursed") );
			else if (charge <= 0)  GLog.i( Messages.get(this, "no_charge") );
			else {
				stealthed = true;
				hero.spend( 1f );
				hero.busy();
				Sample.INSTANCE.play(Assets.SND_MELD);
				activeBuff = activeBuff();
				activeBuff.attachTo(hero);
				if (hero.sprite.parent != null) {
					hero.sprite.parent.add(new AlphaTweener(hero.sprite, 0.4f, 0.4f));
				} else {
					hero.sprite.alpha(0.4f);
				}
				hero.sprite.operate(hero.pos);
			}
		} else {
			stealthed = false;
			activeBuff.detach();
			activeBuff = null;
			hero.spend( 1f );
			hero.sprite.operate( hero.pos );
		}

	}
}
 
Example #28
Source File: CityBossLevel.java    From pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void press( int cell, Char hero ) {
	
	super.press( cell, hero );
	
	if (!enteredArena && outsideEntraceRoom( cell ) && hero == Dungeon.hero) {
		
		enteredArena = true;
		
		Mob boss = Bestiary.mob( Dungeon.depth );
		boss.state = boss.HUNTING;
		int count = 0;
		do {
			boss.pos = Random.Int( LENGTH );
		} while (
			!passable[boss.pos] ||
			!outsideEntraceRoom( boss.pos ) ||
			(Dungeon.visible[boss.pos] && count++ < 20));
		GameScene.add( boss );
		
		if (Dungeon.visible[boss.pos]) {
			boss.notice();
			boss.sprite.alpha( 0 );
			boss.sprite.parent.add( new AlphaTweener( boss.sprite, 1, 0.1f ) );
		}
		
		set( arenaDoor, Terrain.LOCKED_DOOR );
		GameScene.updateMap( arenaDoor );
		Dungeon.observe();
	}
}
 
Example #29
Source File: Honeypot.java    From pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
private void shatter( int pos ) {
	Sample.INSTANCE.play( Assets.SND_SHATTER );
	
	if (Dungeon.visible[pos]) {
		Splash.at( pos, 0xffd500, 5 );
	}
	
	int newPos = pos;
	if (Actor.findChar( pos ) != null) {
		ArrayList<Integer> candidates = new ArrayList<Integer>();
		boolean[] passable = Level.passable;
		
		for (int n : Level.NEIGHBOURS4) {
			int c = pos + n;
			if (passable[c] && Actor.findChar( c ) == null) {
				candidates.add( c );
			}
		}

		newPos = candidates.size() > 0 ? Random.element( candidates ) : -1;
	}
	
	if (newPos != -1) {
		Bee bee = new Bee();
		bee.spawn( Dungeon.depth );
		bee.HP = bee.HT;
		bee.pos = newPos;
		
		GameScene.add( bee );
		Actor.addDelayed( new Pushing( bee, pos, newPos ), -1 );
		
		bee.sprite.alpha( 0 );
		bee.sprite.parent.add( new AlphaTweener( bee.sprite, 1, 0.15f ) );
		
		Sample.INSTANCE.play( Assets.SND_BEE );
	}
}
 
Example #30
Source File: NewPrisonBossLevel.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
private void setFade( ){
	if (vis == null){
		return;
	}
	
	vis.alpha( initialAlpha );
	Actor.addDelayed(new Actor() {
		
		{
			actPriority = HERO_PRIO+1;
		}
		
		@Override
		protected boolean act() {
			Actor.remove(this);
			
			if (vis != null && vis.parent != null) {
				Dungeon.level.customTiles.remove(FadingTraps.this);
				vis.parent.add(new AlphaTweener(vis, 0f, fadeDuration) {
					@Override
					protected void onComplete() {
						super.onComplete();
						vis.killAndErase();
						killAndErase();
					}
				});
			}
			
			return true;
		}
	}, fadeDelay);
}