Merging Source v1.7.2: sprite changes
This commit is contained in:
@@ -24,10 +24,16 @@ import com.watabou.gltextures.TextureCache;
|
||||
import com.watabou.noosa.Camera;
|
||||
import com.watabou.noosa.Image;
|
||||
import com.watabou.noosa.TextureFilm;
|
||||
import com.watabou.noosa.Visual;
|
||||
import com.watabou.noosa.tweeners.Tweener;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
import com.watabou.utils.Callback;
|
||||
import com.watabou.utils.PointF;
|
||||
|
||||
public class HeroSprite extends CharSprite {
|
||||
|
||||
@@ -39,6 +45,9 @@ public class HeroSprite extends CharSprite {
|
||||
private static TextureFilm tiers;
|
||||
|
||||
private Animation fly;
|
||||
|
||||
private Tweener jumpTweener;
|
||||
private Callback jumpCallback;
|
||||
|
||||
public HeroSprite() {
|
||||
super();
|
||||
@@ -90,8 +99,36 @@ public class HeroSprite extends CharSprite {
|
||||
}
|
||||
Camera.main.target = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public void jump( int from, int to, Callback callback ) {
|
||||
jumpCallback = callback;
|
||||
|
||||
int distance = Level.distance( from, to );
|
||||
jumpTweener = new JumpTweener( this, worldToCamera( to ), distance * 4, distance * 0.1f );
|
||||
jumpTweener.listener = this;
|
||||
parent.add( jumpTweener );
|
||||
|
||||
turnTo( from, to );
|
||||
play( fly );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete( Tweener tweener ) {
|
||||
if (tweener == jumpTweener) {
|
||||
|
||||
if (visible && Level.water[ch.pos] && !ch.flying) {
|
||||
GameScene.ripple( ch.pos );
|
||||
}
|
||||
if (jumpCallback != null) {
|
||||
jumpCallback.call();
|
||||
}
|
||||
|
||||
} else {
|
||||
super.onComplete( tweener );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
sleeping = ((Hero)ch).restoreHealth;
|
||||
|
||||
@@ -124,4 +161,28 @@ public class HeroSprite extends CharSprite {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
private static class JumpTweener extends Tweener {
|
||||
|
||||
public Visual visual;
|
||||
|
||||
public PointF start;
|
||||
public PointF end;
|
||||
|
||||
public float height;
|
||||
|
||||
public JumpTweener( Visual visual, PointF pos, float height, float time ) {
|
||||
super( visual, time );
|
||||
|
||||
this.visual = visual;
|
||||
start = visual.point();
|
||||
end = pos;
|
||||
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateValues( float progress ) {
|
||||
visual.point( PointF.inter( start, end, progress ).offset( 0, -height * 4 * progress * (1 - progress) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user