Java源码示例:com.watabou.noosa.tweeners.PosTweener
示例1
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();
}
示例2
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);
}
}
});
}
示例3
@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;
}
}
示例4
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();
}
}
示例5
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);
}
}
}
示例6
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 );
}
示例7
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 );
}
示例8
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 );
}
示例9
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();
}
示例10
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 );
}
}
示例11
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 );
}
}
示例12
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();
}
示例13
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 );
}
示例14
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 );
}