1
0
Fork 0

Added basic "playing" ship indicator for arena

This commit is contained in:
Michaël Lemaire 2015-01-23 01:00:00 +01:00 committed by Michaël Lemaire
parent d69459a7e3
commit e357686a64
5 changed files with 33 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 B

View file

@ -18,6 +18,7 @@ module SpaceTac.View {
this.load.image("battle-actionpointsempty", "assets/images/battle/actionpointsempty.png");
this.load.image("battle-actionpointsfull", "assets/images/battle/actionpointsfull.png");
this.load.image("battle-arena-shipspritehover", "assets/images/battle/arena/shipspritehover.png");
this.load.image("battle-arena-shipspriteplaying", "assets/images/battle/arena/shipspriteplaying.png");
this.load.image("battle-ship-card", "assets/images/battle/ship-card.png");
this.load.image("battle-arena-ship01", "assets/images/battle/arena/ship01.png");
this.load.image("common-standard-bar-background", "assets/images/common/standard-bar-background.png");

View file

@ -16,10 +16,14 @@ module SpaceTac.View {
// List of ship sprites
private ship_sprites: ArenaShip[];
// Currently playing ship
private playing: ArenaShip;
// Create a graphical arena for ship sprites to fight in a 2D space
constructor(battleview: BattleView) {
this.battleview = battleview;
this.ship_sprites = [];
this.playing = null;
super(battleview.game);
@ -82,5 +86,17 @@ module SpaceTac.View {
arena_ship.setHovered(hovered);
}
}
// Set the playing state on a ship sprite
setShipPlaying(ship: Game.Ship): void {
if (this.playing) {
this.playing.setPlaying(false);
}
var arena_ship = this.findShipSprite(ship);
if (arena_ship) {
arena_ship.setPlaying(true);
}
this.playing = arena_ship;
}
}
}

View file

@ -12,6 +12,9 @@ module SpaceTac.View {
// Hover effect
hover: Phaser.Image;
// Playing effect
playing: Phaser.Image;
// Create a ship sprite usable in the Arena
constructor(battleview: BattleView, ship: Game.Ship) {
this.ship = ship;
@ -32,6 +35,12 @@ module SpaceTac.View {
this.sprite.anchor.set(0.5, 0.5);
this.addChild(this.sprite);
// Add playing effect
this.playing = new Phaser.Image(battleview.game, 0, 0, "battle-arena-shipspriteplaying", 0);
this.playing.anchor.set(0.5, 0.5);
this.playing.visible = false;
this.addChild(this.playing);
// Handle input on ship sprite
this.sprite.input.useHandCursor = true;
this.sprite.onInputOver.add(() => {
@ -54,6 +63,12 @@ module SpaceTac.View {
this.hover.visible = hovered;
}
// Set the playing state on this ship
// This will toggle the "playing" indicator
setPlaying(playing: boolean) {
this.playing.visible = playing;
}
// Move the sprite to a location
moveTo(x: number, y: number, animate: boolean = true) {
var angle = Math.atan2(y - this.y, x - this.x);

View file

@ -35,6 +35,7 @@ module SpaceTac.View {
switch (event.code) {
case "ship_change":
// Playing ship changed
this.view.arena.setShipPlaying(event.target.ship);
this.view.card_playing.setShip(event.target.ship);
this.view.action_bar.setShip(event.target.ship);
break;