v0.3.0: added sprite emitter functionality to item sprites in all cases

This commit is contained in:
Evan Debenham 2015-05-26 13:22:49 -04:00
parent 153328aa86
commit 712df97bed
4 changed files with 19 additions and 9 deletions

View File

@ -188,7 +188,10 @@ public class Heap implements Bundlable {
} }
if (sprite != null) { if (sprite != null) {
sprite.view( image(), glowing() ); if (type == Type.HEAP || type == Type.FOR_SALE)
sprite.view( item );
else
sprite.view( image(), glowing() );
} }
} }

View File

@ -160,6 +160,7 @@ public class ItemSprite extends MovieClip {
} }
public ItemSprite view(Item item){ public ItemSprite view(Item item){
view(item.image(), item.glowing());
if (this.emitter != null) this.emitter.on = false; if (this.emitter != null) this.emitter.on = false;
Emitter emitter = item.emitter(); Emitter emitter = item.emitter();
if (emitter != null && parent != null) { if (emitter != null && parent != null) {
@ -167,10 +168,12 @@ public class ItemSprite extends MovieClip {
parent.add( emitter ); parent.add( emitter );
this.emitter = emitter; this.emitter = emitter;
} }
return view(item.image(), item.glowing()); return this;
} }
public ItemSprite view( int image, Glowing glowing ) { public ItemSprite view( int image, Glowing glowing ) {
if (this.emitter != null) this.emitter.on = false;
emitter = null;
frame( film.get( image ) ); frame( film.get( image ) );
if ((this.glowing = glowing) == null) { if ((this.glowing = glowing) == null) {
resetColor(); resetColor();
@ -178,6 +181,12 @@ public class ItemSprite extends MovieClip {
return this; return this;
} }
@Override
public void kill() {
super.kill();
if (emitter != null) emitter.on = false;
}
@Override @Override
public void update() { public void update() {
super.update(); super.update();

View File

@ -44,10 +44,10 @@ public class IconTitle extends Component {
} }
public IconTitle( Item item ) { public IconTitle( Item item ) {
this( ItemSprite icon = new ItemSprite();
new ItemSprite( item ), icon( icon );
Utils.capitalize( item.toString() ) ); label( Utils.capitalize( item.toString() ) );
icon.view( item );
} }
public IconTitle( Image icon, String label ) { public IconTitle( Image icon, String label ) {

View File

@ -40,9 +40,7 @@ public class WndItem extends Window {
super(); super();
IconTitle titlebar = new IconTitle(); IconTitle titlebar = new IconTitle( item );
titlebar.icon( new ItemSprite( item ) );
titlebar.label( Utils.capitalize( item.toString() ) );
titlebar.setRect( 0, 0, WIDTH, 0 ); titlebar.setRect( 0, 0, WIDTH, 0 );
add( titlebar ); add( titlebar );