Merging Source v1.7.2: sprite changes
This commit is contained in:
parent
33db534e25
commit
9f49d115d2
|
@ -83,6 +83,9 @@ public class CharSprite extends MovieClip implements Tweener.Listener, MovieClip
|
||||||
// Char owner
|
// Char owner
|
||||||
public Char ch;
|
public Char ch;
|
||||||
|
|
||||||
|
// The sprite is currently in motion
|
||||||
|
public boolean isMoving = false;
|
||||||
|
|
||||||
public CharSprite() {
|
public CharSprite() {
|
||||||
super();
|
super();
|
||||||
listener = this;
|
listener = this;
|
||||||
|
@ -136,11 +139,15 @@ public class CharSprite extends MovieClip implements Tweener.Listener, MovieClip
|
||||||
motion.listener = this;
|
motion.listener = this;
|
||||||
parent.add( motion );
|
parent.add( motion );
|
||||||
|
|
||||||
|
isMoving = true;
|
||||||
|
|
||||||
turnTo( from , to );
|
turnTo( from , to );
|
||||||
|
|
||||||
if (visible && Level.water[from] && !ch.flying) {
|
if (visible && Level.water[from] && !ch.flying) {
|
||||||
GameScene.ripple( from );
|
GameScene.ripple( from );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ch.onMotionComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void interruptMotion() {
|
public void interruptMotion() {
|
||||||
|
@ -377,6 +384,9 @@ public class CharSprite extends MovieClip implements Tweener.Listener, MovieClip
|
||||||
@Override
|
@Override
|
||||||
public void onComplete( Tweener tweener ) {
|
public void onComplete( Tweener tweener ) {
|
||||||
if (tweener == motion) {
|
if (tweener == motion) {
|
||||||
|
|
||||||
|
isMoving = false;
|
||||||
|
|
||||||
motion.killAndErase();
|
motion.killAndErase();
|
||||||
motion = null;
|
motion = null;
|
||||||
ch.onMotionComplete();
|
ch.onMotionComplete();
|
||||||
|
|
|
@ -24,10 +24,16 @@ import com.watabou.gltextures.TextureCache;
|
||||||
import com.watabou.noosa.Camera;
|
import com.watabou.noosa.Camera;
|
||||||
import com.watabou.noosa.Image;
|
import com.watabou.noosa.Image;
|
||||||
import com.watabou.noosa.TextureFilm;
|
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.Assets;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass;
|
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 {
|
public class HeroSprite extends CharSprite {
|
||||||
|
|
||||||
|
@ -40,6 +46,9 @@ public class HeroSprite extends CharSprite {
|
||||||
|
|
||||||
private Animation fly;
|
private Animation fly;
|
||||||
|
|
||||||
|
private Tweener jumpTweener;
|
||||||
|
private Callback jumpCallback;
|
||||||
|
|
||||||
public HeroSprite() {
|
public HeroSprite() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
@ -91,6 +100,34 @@ public class HeroSprite extends CharSprite {
|
||||||
Camera.main.target = this;
|
Camera.main.target = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
sleeping = ((Hero)ch).restoreHealth;
|
sleeping = ((Hero)ch).restoreHealth;
|
||||||
|
@ -124,4 +161,28 @@ public class HeroSprite extends CharSprite {
|
||||||
return avatar;
|
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;
|
package com.shatteredpixel.shatteredpixeldungeon.sprites;
|
||||||
|
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.watabou.gltextures.TextureCache;
|
import com.watabou.gltextures.TextureCache;
|
||||||
import com.watabou.noosa.Game;
|
import com.watabou.noosa.Game;
|
||||||
|
@ -139,6 +140,9 @@ public class ItemSprite extends MovieClip {
|
||||||
place( from );
|
place( from );
|
||||||
|
|
||||||
speed.offset( (px-x) / DROP_INTERVAL, (py-y) / DROP_INTERVAL );
|
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 MASTERY = ROW2+8;
|
||||||
public static final int KIT = ROW2+9;
|
public static final int KIT = ROW2+9;
|
||||||
public static final int AMULET = ROW2+10;
|
public static final int AMULET = ROW2+10;
|
||||||
|
public static final int WEIGHT = ROW2+11;
|
||||||
|
|
||||||
//Row Three: Melee weapons
|
//Row Three: Melee weapons
|
||||||
public static final int KNUCKLEDUSTER = ROW3+0;
|
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_ROTBERRY = ROW12+0;
|
||||||
public static final int SEED_FIREBLOOM = ROW12+1;
|
public static final int SEED_FIREBLOOM = ROW12+1;
|
||||||
public static final int SEED_BLINDWEED = ROW12+2;
|
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_SUNGRASS = ROW12+3;
|
||||||
public static final int SEED_ICECAP = ROW12+4;
|
public static final int SEED_ICECAP = ROW12+4;
|
||||||
public static final int SEED_SORROWMOSS = ROW12+5;
|
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
|
if (image == ItemSpriteSheet.DART || image == ItemSpriteSheet.INCENDIARY_DART
|
||||||
|| image == ItemSpriteSheet.CURARE_DART || image == ItemSpriteSheet.JAVELIN) {
|
|| image == ItemSpriteSheet.CURARE_DART || image == ItemSpriteSheet.JAVELIN) {
|
||||||
|
|
||||||
angularSpeed = 0;
|
angularSpeed = 0;
|
||||||
angle = 135 - (float)(Math.atan2( d.x, d.y ) / 3.1415926 * 180);
|
angle = 135 - (float)(Math.atan2( d.x, d.y ) / 3.1415926 * 180);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
angularSpeed = image == 15 || image == 106 ? 1440 : 720;
|
angularSpeed = image == 15 || image == 106 ? 1440 : 720;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PosTweener tweener = new PosTweener( this, dest, d.length() / SPEED );
|
PosTweener tweener = new PosTweener( this, dest, d.length() / SPEED );
|
||||||
|
|
|
@ -31,8 +31,7 @@ public class MobSprite extends CharSprite {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
sleeping = ch != null && ((Mob)ch).state == Mob.State.SLEEPING;
|
sleeping = ch != null && ((Mob)ch).state == ((Mob)ch).SLEEPEING;
|
||||||
|
|
||||||
super.update();
|
super.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,8 @@ import com.watabou.noosa.TextureFilm;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.DungeonTilemap;
|
import com.shatteredpixel.shatteredpixeldungeon.DungeonTilemap;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.plants.Plant;
|
import com.shatteredpixel.shatteredpixeldungeon.plants.Plant;
|
||||||
|
import com.watabou.utils.PointF;
|
||||||
|
|
||||||
public class PlantSprite extends Image {
|
public class PlantSprite extends Image {
|
||||||
|
|
||||||
|
@ -65,8 +65,9 @@ public class PlantSprite extends Image {
|
||||||
alpha( 1f );
|
alpha( 1f );
|
||||||
|
|
||||||
pos = plant.pos;
|
pos = plant.pos;
|
||||||
x = pos % Level.WIDTH * DungeonTilemap.SIZE;
|
PointF p = DungeonTilemap.tileToWorld( plant.pos );
|
||||||
y = pos / Level.WIDTH * DungeonTilemap.SIZE;
|
x = p.x;
|
||||||
|
y = p.y;
|
||||||
|
|
||||||
state = State.GROWING;
|
state = State.GROWING;
|
||||||
time = DELAY;
|
time = DELAY;
|
||||||
|
|
|
@ -60,9 +60,13 @@ public class TenguSprite extends MobSprite {
|
||||||
play( run );
|
play( run );
|
||||||
turnTo( from , to );
|
turnTo( from , to );
|
||||||
|
|
||||||
|
isMoving = true;
|
||||||
|
|
||||||
if (Level.water[to]) {
|
if (Level.water[to]) {
|
||||||
GameScene.ripple( to );
|
GameScene.ripple( to );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ch.onMotionComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -90,8 +94,8 @@ public class TenguSprite extends MobSprite {
|
||||||
@Override
|
@Override
|
||||||
public void onComplete( Animation anim ) {
|
public void onComplete( Animation anim ) {
|
||||||
if (anim == run) {
|
if (anim == run) {
|
||||||
|
isMoving = false;
|
||||||
idle();
|
idle();
|
||||||
ch.onMotionComplete();
|
|
||||||
} else {
|
} else {
|
||||||
super.onComplete( anim );
|
super.onComplete( anim );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user