Skip to content

Commit

Permalink
Fixed support for headless mode
Browse files Browse the repository at this point in the history
  • Loading branch information
ekelokorpi committed Jan 14, 2019
1 parent 9c0f7be commit 94f27ee
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/engine/renderer/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -791,8 +791,10 @@ game.addAttributes('Container', {
_context: null
});

game.Container._canvas = document.createElement('canvas');
game.Container._context = game.Container._canvas.getContext('2d');
if (typeof document !== 'undefined') {
game.Container._canvas = document.createElement('canvas');
game.Container._context = game.Container._canvas.getContext('2d');
}

game.defineProperties('Container', {
/**
Expand Down
6 changes: 4 additions & 2 deletions src/engine/renderer/sprite.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,9 @@ game.addAttributes('Sprite', {
}
});

game.Sprite._canvas = document.createElement('canvas');
game.Sprite._context = game.Sprite._canvas.getContext('2d');
if (typeof document !== 'undefined') {
game.Sprite._canvas = document.createElement('canvas');
game.Sprite._context = game.Sprite._canvas.getContext('2d');
}

});
6 changes: 4 additions & 2 deletions src/engine/renderer/tilingsprite.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,10 @@ game.addAttributes('TilingSprite', {
}
});

game.TilingSprite._canvas = document.createElement('canvas');
game.TilingSprite._context = game.TilingSprite._canvas.getContext('2d');
if (typeof document !== 'undefined') {
game.TilingSprite._canvas = document.createElement('canvas');
game.TilingSprite._context = game.TilingSprite._canvas.getContext('2d');
}

game.defineProperties('TilingSprite', {
width: {
Expand Down

0 comments on commit 94f27ee

Please sign in to comment.