v0.6.1: added a persistent health bar to the sad ghost
This commit is contained in:
parent
b2ca8a3426
commit
0cdd99e389
|
@ -156,6 +156,9 @@ public class GameScene extends PixelScene {
|
|||
private ActionIndicator action;
|
||||
private ResumeIndicator resume;
|
||||
|
||||
//temporary, see Ghostsprite
|
||||
public Group ghostHP;
|
||||
|
||||
@Override
|
||||
public void create() {
|
||||
|
||||
|
@ -231,6 +234,8 @@ public class GameScene extends PixelScene {
|
|||
mobs = new Group();
|
||||
add( mobs );
|
||||
|
||||
ghostHP = new Group();
|
||||
|
||||
for (Mob mob : Dungeon.level.mobs) {
|
||||
addMobSprite( mob );
|
||||
if (Statistics.amuletObtained) {
|
||||
|
@ -281,6 +286,8 @@ public class GameScene extends PixelScene {
|
|||
|
||||
add( new HealthIndicator() );
|
||||
|
||||
add( ghostHP );
|
||||
|
||||
add( cellSelector = new CellSelector( tiles ) );
|
||||
|
||||
pane = new StatusPane();
|
||||
|
|
|
@ -22,15 +22,26 @@
|
|||
package com.shatteredpixel.shatteredpixeldungeon.sprites;
|
||||
|
||||
import android.opengl.GLES20;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ShaftParticle;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.DriedRose;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.HealthBar;
|
||||
import com.watabou.noosa.TextureFilm;
|
||||
|
||||
import javax.microedition.khronos.opengles.GL10;
|
||||
|
||||
//FIXME the healthbar added here is a quick fix.
|
||||
// The game should have a much more flexible health bar system which works for any character
|
||||
// However I want a ghost HP bar to get into 0.6.1, so this will have to do for now.
|
||||
public class GhostSprite extends MobSprite {
|
||||
|
||||
private HealthBar hpBar;
|
||||
|
||||
public GhostSprite() {
|
||||
super();
|
||||
|
||||
|
@ -53,6 +64,24 @@ public class GhostSprite extends MobSprite {
|
|||
play( idle );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void link(Char ch) {
|
||||
super.link(ch);
|
||||
if (ch instanceof DriedRose.GhostHero){
|
||||
final Char finalCH = ch;
|
||||
hpBar = new HealthBar(){
|
||||
@Override
|
||||
public synchronized void update() {
|
||||
super.update();
|
||||
hpBar.setRect(finalCH.sprite.x, finalCH.sprite.y-3, finalCH.sprite.width, hpBar.height());
|
||||
hpBar.level( finalCH );
|
||||
visible = finalCH.sprite.visible;
|
||||
}
|
||||
};
|
||||
((GameScene)ShatteredPixelDungeon.scene()).ghostHP.add(hpBar);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw() {
|
||||
GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE );
|
||||
|
@ -63,6 +92,7 @@ public class GhostSprite extends MobSprite {
|
|||
@Override
|
||||
public void die() {
|
||||
super.die();
|
||||
if (hpBar != null) hpBar.killAndErase();
|
||||
emitter().start( ShaftParticle.FACTORY, 0.3f, 4 );
|
||||
emitter().start( Speck.factory( Speck.LIGHT ), 0.2f, 3 );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user