-
-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: GraphicsGroup null/undefined guard to prevent crash
- Loading branch information
Showing
6 changed files
with
78 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Graphics Padding Test</title> | ||
</head> | ||
<body> | ||
<script src="../../lib/excalibur.js"></script> | ||
<script src="index.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/// <reference path="../../lib/excalibur.d.ts" /> | ||
|
||
var game = new ex.Engine({ | ||
width: 1000, | ||
height: 1000, | ||
}); | ||
|
||
var heartImage = new ex.ImageSource('./heart.png'); | ||
|
||
var loader = new ex.Loader([heartImage]) | ||
|
||
class MyActor2 extends ex.Actor { | ||
constructor() { | ||
super({ | ||
pos: ex.vec(200, 200) | ||
}); | ||
} | ||
onInitialize() { | ||
this.graphics.add( | ||
"interactive", | ||
new ex.GraphicsGroup({ | ||
members: [ | ||
{ | ||
graphic: undefined, | ||
offset: ex.vec(8, 8), | ||
}, | ||
{ | ||
graphic: heartImage.toSprite(), | ||
offset: ex.vec(8, -16), | ||
}, | ||
], | ||
}), | ||
{ | ||
anchor: ex.vec(0, 0), | ||
} | ||
); | ||
this.graphics.add( | ||
"noninteractive", | ||
heartImage.toSprite(), | ||
{ | ||
anchor: ex.vec(8, 8), | ||
} | ||
) | ||
} | ||
|
||
onPreUpdate(engine: ex.Engine<any>, delta: number): void { | ||
this.graphics.use("interactive"); | ||
} | ||
} | ||
|
||
game.add(new MyActor2()); | ||
|
||
game.start(loader) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters