Skip to content

Commit

Permalink
Remove visual artifacts when resizing window
Browse files Browse the repository at this point in the history
  • Loading branch information
elliotbonneville committed Aug 31, 2015
1 parent 2dd65f4 commit ede3aa2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 17 deletions.
16 changes: 8 additions & 8 deletions build/application.js

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions src/js/actor.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ Actor.prototype = {
}

// this move would mean that the actor is moving into the opponent's net
if (tile.zone === "goal" &&
tile.owner !== this.owner) {

if (tile.zone === "goal" && tile.owner !== this.owner) {
return false;
}

Expand Down
1 change: 1 addition & 0 deletions src/js/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ function Controller() {
},

"window resize": function () {
self.clearUIState();
self.view.display.resizeBoard();
}
});
Expand Down
20 changes: 14 additions & 6 deletions src/js/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ Display.prototype = {
// draw and store the actors
createActors: function () {
var actor,
clip,
i;

// draw actors
Expand All @@ -132,7 +131,7 @@ Display.prototype = {
.use(this.symbols.x)
.style("pointer-events", "none");
} else if (actor.owner === Player.Two) {
clip = this.actors[i].draw
this.actors[i].clip = this.actors[i].draw
.circle(this.actorDiameter)
.move(this.actorOffset, this.actorOffset);

Expand All @@ -141,7 +140,7 @@ Display.prototype = {
width: settings.actorBorderWidth * 2,
color: settings.colors.actors.border
})
.clipWith(clip);
.clipWith(this.actors[i].clip);
}

if (actor.owner === this.board.settings.owner) {
Expand Down Expand Up @@ -570,11 +569,20 @@ Display.prototype = {
// update the size and position of a single actor
updateActor: function (index) {
var actor = this.board.actors[index];
this.actors[index].draw.move(actor.x * this.tileSize,
actor.y * this.tileSize);
this.actors[index].element.size(this.actorDiameter)

this.actors[index].draw
.move(actor.x * this.tileSize, actor.y * this.tileSize);

this.actors[index].element
.size(this.actorDiameter)
.move(this.actorOffset, this.actorOffset);

if (actor.owner === Player.Two) {
this.actors[index].clip
.size(this.actorDiameter)
.move(this.actorOffset, this.actorOffset);
}

if (this.actors[index].symbol) {
this.actors[index].symbol.remove();
this.actors[index].symbol = this.actors[index].draw
Expand Down

0 comments on commit ede3aa2

Please sign in to comment.