Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,25 @@
"dprint.path": "./node_modules/dprint/dprint",
"cSpell.words": [
"anims",
"Aseprite",
"Bbox",
"beant",
"bobo",
"gopt",
"kaplay",
"lajbel",
"lerp",
"lshoulder",
"lstick",
"ltrigger",
"minver",
"mult",
"verts"
"rshoulder",
"rstick",
"rtrigger",
"skuller",
"sukomi",
"verts",
"zombean"
]
}
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ So your change should look like:

### Fixed

- Fixed the Aseprite loader using the wrong frames sizes (#1102) -
@dragoncoder047
- Made the texture packer 3x faster (#1102) - @dragoncoder047
- Fixed `TimerController.timeLeft` returning elapsed time instead of remaining
time (#1082) - @nojaf
- Fixed mouse coordinates not being calculated properly when canvas is resized
Expand Down
32 changes: 12 additions & 20 deletions src/assets/aseprite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export type AsepriteData = {
};
}>;
meta: {
size: { w: number; h: number };
frameTags: Array<{
name: string;
from: number;
Expand Down Expand Up @@ -47,34 +46,27 @@ export function loadAseprite(

return _k.assets.sprites.add(
name,
resolveJSON.then((data: AsepriteData) => {
const size = data.meta.size;
const frames = data.frames.map((f: any) => {
return new Quad(
f.frame.x / size.w,
f.frame.y / size.h,
f.frame.w / size.w,
f.frame.h / size.h,
);
});
const anims: Record<string, number | SpriteAnim> = {};
resolveJSON.then(({ meta: { frameTags }, frames }: AsepriteData) => {
const anims: Record<string, SpriteAnim> = {};

for (const anim of data.meta.frameTags) {
if (anim.from === anim.to) {
anims[anim.name] = anim.from;
for (const { name, from, to, direction } of frameTags) {
if (from === to) {
anims[name] = from;
}
else {
anims[anim.name] = {
from: anim.from,
to: anim.to,
anims[name] = {
from,
to,
speed: 10,
loop: true,
pingpong: anim.direction === "pingpong",
pingpong: direction === "pingpong",
};
}
}
return SpriteData.fromSpriteSrc(imgSrc, {
frames: frames,
frames: frames.map(({ frame: { x, y, w, h } }) =>
new Quad(x, y, w, h)
),
anims: anims,
repack: false,
});
Expand Down
Loading