Skip to content

Commit 52c3f28

Browse files
committed
add beetle resource
1 parent eda9b15 commit 52c3f28

File tree

7 files changed

+61
-18
lines changed

7 files changed

+61
-18
lines changed

package-lock.json

Lines changed: 40 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@
3333
"serve": "14.2.4"
3434
},
3535
"dependencies": {
36-
"excalibur": "0.30.0-alpha.1295"
36+
"excalibur": "0.30.3",
37+
"@excaliburjs/plugin-aseprite": "0.30.2"
3738
},
3839
"homepage": "",
3940
"repository": {},
4041
"bugs": {}
41-
}
42+
}

src/files.d.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
declare module "*.png" {
22
const val: string;
33
export default val;
4-
}
4+
}
5+
6+
7+
declare module "*.aseprite" {
8+
const val: string;
9+
export default val;
10+
}

src/images/beetle.aseprite

3.47 KB
Binary file not shown.

src/player.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class Player extends Actor {
2828
// anchor: vec(0, 0), // Actors default center colliders and graphics with anchor (0.5, 0.5)
2929
// collisionType: CollisionType.Active, // Collision Type Active means this participates in collisions read more https://excaliburjs.com/docs/collisiontypes
3030
});
31-
31+
3232
}
3333

3434
override onInitialize() {
@@ -39,15 +39,15 @@ export class Player extends Actor {
3939
// 2. You need excalibur to be initialized & started
4040
// 3. Deferring logic to run time instead of constructor time
4141
// 4. Lazy instantiation
42-
this.graphics.add(Resources.Sword.toSprite());
42+
this.graphics.add(Resources.BeetleAseprite.getAnimation('Loop'));
4343

4444
// Actions are useful for scripting common behavior, for example patrolling enemies
4545
this.actions.delay(2000);
4646
this.actions.repeatForever(ctx => {
47-
ctx.moveBy({offset: vec(100, 0), durationMs: 1000});
48-
ctx.moveBy({offset: vec(0, 100), durationMs: 1000});
49-
ctx.moveBy({offset: vec(-100, 0), durationMs: 1000});
50-
ctx.moveBy({offset: vec(0, -100), durationMs: 1000});
47+
ctx.moveBy({ offset: vec(100, 0), duration: 1000 });
48+
ctx.moveBy({ offset: vec(0, 100), duration: 1000 });
49+
ctx.moveBy({ offset: vec(-100, 0), duration: 1000 });
50+
ctx.moveBy({ offset: vec(0, -100), duration: 1000 });
5151
});
5252

5353
// Sometimes you want to click on an actor!

src/resources.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import { ImageSource, Loader } from "excalibur";
2+
import { AsepriteResource } from "@excaliburjs/plugin-aseprite";
23
import swordPath from './images/sword.png'; // Webpack asset/resource loader will find the image path
4+
import beetlePath from './images/beetle.aseprite';
35

46
// It is convenient to put your resources in one place
57
export const Resources = {
6-
Sword: new ImageSource(swordPath)
8+
Sword: new ImageSource(swordPath),
9+
BeetleAseprite: new AsepriteResource(beetlePath)
710
} as const; // the 'as const' is a neat typescript trick to get strong typing on your resources.
811
// So when you type Resources.Sword -> ImageSource
912

webpack.common.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module.exports = {
1414
module: {
1515
rules: [
1616
{
17-
test: /\.(png|svg|jpg|jpeg|gif)$/i,
17+
test: /\.(png|svg|jpg|jpeg|gif|aseprite)$/i,
1818
type: "asset/resource",
1919
},
2020
{

0 commit comments

Comments
 (0)