-
-
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: Invalid color argument type when providing collider
- Loading branch information
Showing
4 changed files
with
93 additions
and
0 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
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,15 @@ | ||
<!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>Composite Collider</title> | ||
</head> | ||
|
||
<body> | ||
<p>Composite Collider</p> | ||
<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,64 @@ | ||
/// <reference path='../../lib/excalibur.d.ts' /> | ||
|
||
var game = new ex.Engine({ | ||
width: 1000, | ||
height: 1000, | ||
physics: { | ||
solver: ex.SolverStrategy.Arcade | ||
} | ||
}); | ||
|
||
game.toggleDebug(); | ||
|
||
let roomShape = new ex.Rectangle({ width: 700, height: 500, color: ex.Color.DarkGray, strokeColor: ex.Color.White }); | ||
|
||
var topEdgeCollider = ex.Shape.Box(700, 10, ex.Vector.Zero, ex.vec(0, 0)); | ||
var leftEdgeCollider = ex.Shape.Box(10, 500, ex.Vector.Zero, ex.vec(0, 0)); | ||
var rightEdgeCollider = ex.Shape.Box(10, 500, ex.Vector.One, ex.vec(700, 500)); | ||
var bottomEdgeCollider = ex.Shape.Box(700, 10, ex.Vector.One, ex.vec(700, 500)); | ||
var compositeCollider = new ex.CompositeCollider([topEdgeCollider, leftEdgeCollider, rightEdgeCollider, bottomEdgeCollider]); | ||
|
||
class RoomActor extends ex.Actor { | ||
roomId: string; | ||
constructor() { | ||
super({ | ||
pos: new ex.Vector(0, 0), | ||
collider: compositeCollider, | ||
collisionType: ex.CollisionType.Fixed | ||
}); | ||
this.graphics.anchor = ex.vec(0, 0); | ||
this.graphics.use(roomShape); | ||
} | ||
} | ||
game.add(new RoomActor()); | ||
|
||
var player = new ex.Actor({ | ||
pos: ex.vec(100, 270), | ||
width: 16, | ||
height: 16, | ||
color: ex.Color.Blue, | ||
collisionType: ex.CollisionType.Active | ||
}); | ||
|
||
player.onPostUpdate = () => { | ||
const speed = 164; | ||
player.vel = ex.vec(0, 0); | ||
if (game.input.keyboard.isHeld(ex.Keys.Right)) { | ||
player.vel.x = speed; | ||
} | ||
if (game.input.keyboard.isHeld(ex.Keys.Left)) { | ||
player.vel.x = -speed; | ||
} | ||
if (game.input.keyboard.isHeld(ex.Keys.Up)) { | ||
player.vel.y = -speed; | ||
} | ||
if (game.input.keyboard.isHeld(ex.Keys.Down)) { | ||
player.vel.y = speed; | ||
} | ||
}; | ||
game.add(player); | ||
|
||
game.currentScene.camera.strategy.elasticToActor(player, 0.8, 0.9); | ||
game.currentScene.camera.zoom = 2; | ||
|
||
game.start(); |
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