com.watabou.noosa.tweeners.PosTweener Java Examples

The following examples show how to use com.watabou.noosa.tweeners.PosTweener. 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: CharSprite.java    From pixel-dungeon with GNU General Public License v3.0 6 votes vote down vote up
public void move( int from, int to ) {
	play( run );
	
	motion = new PosTweener( this, worldToCamera( to ), MOVE_INTERVAL );
	motion.listener = this;
	parent.add( motion );

	isMoving = true;
	
	turnTo( from , to );
	
	if (visible && Level.water[from] && !ch.flying) {
		GameScene.ripple( from );
	}
	
	ch.onMotionComplete();
}
 
Example #2
Source File: CharSprite.java    From remixed-dungeon with GNU General Public License v3.0 6 votes vote down vote up
public void move(int from, int to, boolean playRunAnimation) {
    ch.ifPresent(chr -> {
        if (playRunAnimation) {
            play(run);
        }

        if (getParent() != null) {
            motion = new PosTweener(this, worldToCamera(to), MOVE_INTERVAL);
            motion.listener = this;
            getParent().add(motion);

            isMoving = true;

            turnTo(from, to);

            if (getVisible() && Dungeon.level.water[from] && !chr.isFlying()) {
                GameScene.ripple(from);
            }
        }
    });
}
 
Example #3
Source File: Pushing.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected boolean act() {

	if (sprite != null) {

               PointF dest = sprite.worldToCamera( to );
               PointF d = PointF.diff( sprite.worldToCamera( from ), dest );

               PosTweener tweener = new PosTweener( sprite, dest, d.length() / SPEED );

               tweener.listener = new Tweener.Listener() {
                   @Override
                   public void onComplete( Tweener tweener ){
                       Actor.remove( Pushing.this );

                       if( callback != null ){
                           callback.call();
                       }

                       next();
                   }
               };

               sprite.parent.add( tweener );

		return false;

	} else {

		Actor.remove( Pushing.this );
		return true;
	}
}
 
Example #4
Source File: CharSprite.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public PointF destinationCenter(){
	PosTweener motion = this.motion;
	if (motion != null){
		return new PointF(motion.end.x + width()/2f, motion.end.y + height()/2f);
	} else {
		return center();
	}
}
 
Example #5
Source File: LevelObjectSprite.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public void move(int from, int to) {
	if (getParent() != null) {
		Tweener motion = new PosTweener(this, DungeonTilemap.tileToWorld(to).offset(centerShift), 0.1f);
		motion.listener = this;
		getParent().add(motion);

		if (getVisible() && Dungeon.level.water[from]) {
			GameScene.ripple(from);
		}
	}
}
 
Example #6
Source File: ZapEffect.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
private static void attachMissileTeenier(Visual target, int from, int to) {

        target.point( DungeonTilemap.tileToWorld( from ) );
        PointF dest = DungeonTilemap.tileToWorld( to );

        PointF d = PointF.diff( dest, target.point() );
        target.speed.set( d ).normalize().scale(SPEED );

        target.angularSpeed = 0;
        target.angle = (float) (135 - Math.toDegrees(Math.atan2( d.x, d.y )));

        PosTweener tweener = new PosTweener( target, dest, d.length() / SPEED );
        tweener.listener = tweener1 -> target.killAndErase();
        target.getParent().add( tweener );
    }
 
Example #7
Source File: MissileSprite.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public void reset(int from, int to, Item item, Callback listener) {
	revive();

	float scale = item.heapScale();
	setScale(scale, scale);
	view(item);

	this.callback = listener;

	point( DungeonTilemap.tileToWorld( from ) );

	PointF dest = DungeonTilemap.tileToWorld( to );

	PointF d = PointF.diff( dest, point() ); 
	speed.set( d ).normalize().scale( ZapEffect.SPEED );

	if (item.isFliesStraight()) {
		angularSpeed = 0;
		angle = 135 - (float)(Math.atan2( d.x, d.y ) / Math.PI * 180);
	} else {
		angularSpeed = item.isFliesFastRotating() ? 1440 : 720;
	}

	PosTweener tweener = new PosTweener( this, dest, d.length() / ZapEffect.SPEED );
	tweener.listener = this;
	getParent().add( tweener );
}
 
Example #8
Source File: MissileSprite.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 4 votes vote down vote up
public void reset( int from, int to, int image, float speed_modifier, Glowing glowing, Callback listener ) {
		revive();
		
		view( image, glowing );
		
		this.callback = listener;

		point( DungeonTilemap.tileToWorld( from ) );
		PointF dest = DungeonTilemap.tileToWorld( to );
		
		PointF d = PointF.diff( dest, point() );

		speed.set( d ).normalize().scale( SPEED * speed_modifier );

        scale.x = 0.8f;
        scale.y = 0.8f;

        // FIXME

		if (
            image == ItemSpriteSheet.THROWING_DART
            || image == ItemSpriteSheet.THROWING_KNIFE
            || image == ItemSpriteSheet.JAVELIN
//            || image == ItemSpriteSheet.HARPOON
            || image == ItemSpriteSheet.HARPOON_THROWN
            || image == ItemSpriteSheet.HARPOON_RETURN
            || image == ItemSpriteSheet.ARROW
            || image == ItemSpriteSheet.QUARREL
        ) {

			angularSpeed = 0;
			angle = ( image != ItemSpriteSheet.HARPOON_RETURN ? 135 : -45 ) - (float)(Math.atan2( d.x, d.y ) / 3.1415926 * 180);
			
		} else {
			
			angularSpeed = 720;
			
		}
		
		PosTweener tweener = new PosTweener( this, dest, d.length() / SPEED );
		tweener.listener = this;
		parent.add( tweener );
	}
 
Example #9
Source File: CharSprite.java    From unleashed-pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
public void move( int from, int to ) {
	turnTo(from, to);

	play( run );
	
	motion = new PosTweener( this, worldToCamera( to ), MOVE_INTERVAL );
	motion.listener = this;
	parent.add( motion );

	isMoving = true;
	
	turnTo( from , to );
	
	if (visible && Level.water[from] && !ch.flying) {
		GameScene.ripple( from );
	}

	ch.onMotionComplete();
}
 
Example #10
Source File: CharSprite.java    From shattered-pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
public void move( int from, int to ) {
	turnTo( from , to );

	play( run );
	
	motion = new PosTweener( this, worldToCamera( to ), moveInterval );
	motion.listener = this;
	parent.add( motion );

	isMoving = true;
	
	if (visible && Dungeon.level.water[from] && !ch.flying) {
		GameScene.ripple( from );
	}

}
 
Example #11
Source File: CharSprite.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 4 votes vote down vote up
public void move( int from, int to ) {
	turnTo( from , to );

	play( run );
	
	motion = new PosTweener( this, worldToCamera( to ), moveInterval);
	motion.listener = this;
	parent.add( motion );

	isMoving = true;
	
	if (visible && Dungeon.level.water[from] && !ch.flying) {
		GameScene.ripple( from );
	}

}
 
Example #12
Source File: CharSprite.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 3 votes vote down vote up
public void move( int from, int to ) {
	play( run );
	
	motion = new PosTweener( this, worldToCamera( to ), MOVE_INTERVAL );
	motion.listener = this;
	parent.add( motion );

	isMoving = true;
	
	turnTo( from , to );
	
	ch.onMotionComplete();
}
 
Example #13
Source File: MissileSprite.java    From unleashed-pixel-dungeon with GNU General Public License v3.0 3 votes vote down vote up
public void reset( int from, int to, int image, Glowing glowing, Callback listener ) {
	revive();
	
	view( image, glowing );
	
	this.callback = listener;

	point( DungeonTilemap.tileToWorld( from ) );
	PointF dest = DungeonTilemap.tileToWorld( to );
	
	PointF d = PointF.diff( dest, point() );
	speed.set( d ).normalize().scale( SPEED );

	if (image == ItemSpriteSheet.DART || image == ItemSpriteSheet.INCENDIARY_DART
			|| image == ItemSpriteSheet.CURARE_DART  || image == ItemSpriteSheet.JAVELIN) {

		angularSpeed = 0;
		angle = 135 - (float)(Math.atan2( d.x, d.y ) / 3.1415926 * 180);

	} else {

		angularSpeed = image == 15 || image == 106 ? 1440 : 720;

	}
	
	PosTweener tweener = new PosTweener( this, dest, d.length() / SPEED );
	tweener.listener = this;
	parent.add( tweener );
}
 
Example #14
Source File: MissileSprite.java    From pixel-dungeon with GNU General Public License v3.0 3 votes vote down vote up
public void reset( int from, int to, int image, Glowing glowing, Callback listener ) {
	revive();
	
	view( image, glowing );
	
	this.callback = listener;

	point( DungeonTilemap.tileToWorld( from ) );
	PointF dest = DungeonTilemap.tileToWorld( to );
	
	PointF d = PointF.diff( dest, point() ); 
	speed.set( d ).normalize().scale( SPEED );
	
	if (image == 31 || image == 108 || image == 109 || image == 110) {

		angularSpeed = 0;
		angle = 135 - (float)(Math.atan2( d.x, d.y ) / 3.1415926 * 180);
		
	} else {
		
		angularSpeed = image == 15 || image == 106 ? 1440 : 720;
		
	}
	
	PosTweener tweener = new PosTweener( this, dest, d.length() / SPEED );
	tweener.listener = this;
	parent.add( tweener );
}