Merging Source v1.7.2: sprite changes
This commit is contained in:
parent
33db534e25
commit
9f49d115d2
|
@ -82,6 +82,9 @@ public class CharSprite extends MovieClip implements Tweener.Listener, MovieClip
|
|||
|
||||
// Char owner
|
||||
public Char ch;
|
||||
|
||||
// The sprite is currently in motion
|
||||
public boolean isMoving = false;
|
||||
|
||||
public CharSprite() {
|
||||
super();
|
||||
|
@ -135,12 +138,16 @@ public class CharSprite extends MovieClip implements Tweener.Listener, MovieClip
|
|||
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();
|
||||
}
|
||||
|
||||
public void interruptMotion() {
|
||||
|
@ -377,6 +384,9 @@ public class CharSprite extends MovieClip implements Tweener.Listener, MovieClip
|
|||
@Override
|
||||
public void onComplete( Tweener tweener ) {
|
||||
if (tweener == motion) {
|
||||
|
||||
isMoving = false;
|
||||
|
||||
motion.killAndErase();
|
||||
motion = null;
|
||||
ch.onMotionComplete();
|
||||
|
|
|
@ -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) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
package com.shatteredpixel.shatteredpixeldungeon.sprites;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.util.Log;
|
||||
|
||||
import com.watabou.gltextures.TextureCache;
|
||||
import com.watabou.noosa.Game;
|
||||
|
@ -139,6 +140,9 @@ public class ItemSprite extends MovieClip {
|
|||
place( from );
|
||||
|
||||
speed.offset( (px-x) / DROP_INTERVAL, (py-y) / DROP_INTERVAL );
|
||||
|
||||
Log.d( "GAME", toString() );
|
||||
Log.d( "GAME", String.format( "drop aside: %.1f %.1f", speed.x, speed.y ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -67,6 +67,7 @@ public class ItemSpriteSheet {
|
|||
public static final int MASTERY = ROW2+8;
|
||||
public static final int KIT = ROW2+9;
|
||||
public static final int AMULET = ROW2+10;
|
||||
public static final int WEIGHT = ROW2+11;
|
||||
|
||||
//Row Three: Melee weapons
|
||||
public static final int KNUCKLEDUSTER = ROW3+0;
|
||||
|
@ -182,6 +183,7 @@ public class ItemSpriteSheet {
|
|||
public static final int SEED_ROTBERRY = ROW12+0;
|
||||
public static final int SEED_FIREBLOOM = ROW12+1;
|
||||
public static final int SEED_BLINDWEED = ROW12+2;
|
||||
public static final int SEED_DREAMWEED = ROW12+2;
|
||||
public static final int SEED_SUNGRASS = ROW12+3;
|
||||
public static final int SEED_ICECAP = ROW12+4;
|
||||
public static final int SEED_SORROWMOSS = ROW12+5;
|
||||
|
|
|
@ -58,10 +58,14 @@ public class MissileSprite extends ItemSprite implements Tweener.Listener {
|
|||
|
||||
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 );
|
||||
|
|
|
@ -31,8 +31,7 @@ public class MobSprite extends CharSprite {
|
|||
|
||||
@Override
|
||||
public void update() {
|
||||
sleeping = ch != null && ((Mob)ch).state == Mob.State.SLEEPING;
|
||||
|
||||
sleeping = ch != null && ((Mob)ch).state == ((Mob)ch).SLEEPEING;
|
||||
super.update();
|
||||
}
|
||||
|
||||
|
|
|
@ -23,8 +23,8 @@ import com.watabou.noosa.TextureFilm;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.DungeonTilemap;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.plants.Plant;
|
||||
import com.watabou.utils.PointF;
|
||||
|
||||
public class PlantSprite extends Image {
|
||||
|
||||
|
@ -65,8 +65,9 @@ public class PlantSprite extends Image {
|
|||
alpha( 1f );
|
||||
|
||||
pos = plant.pos;
|
||||
x = pos % Level.WIDTH * DungeonTilemap.SIZE;
|
||||
y = pos / Level.WIDTH * DungeonTilemap.SIZE;
|
||||
PointF p = DungeonTilemap.tileToWorld( plant.pos );
|
||||
x = p.x;
|
||||
y = p.y;
|
||||
|
||||
state = State.GROWING;
|
||||
time = DELAY;
|
||||
|
|
|
@ -59,10 +59,14 @@ public class TenguSprite extends MobSprite {
|
|||
|
||||
play( run );
|
||||
turnTo( from , to );
|
||||
|
||||
if (Level.water[to]) {
|
||||
|
||||
isMoving = true;
|
||||
|
||||
if (Level.water[to]) {
|
||||
GameScene.ripple( to );
|
||||
}
|
||||
|
||||
ch.onMotionComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -90,8 +94,8 @@ public class TenguSprite extends MobSprite {
|
|||
@Override
|
||||
public void onComplete( Animation anim ) {
|
||||
if (anim == run) {
|
||||
idle();
|
||||
ch.onMotionComplete();
|
||||
isMoving = false;
|
||||
idle();
|
||||
} else {
|
||||
super.onComplete( anim );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user