Skip to content

Commit

Permalink
Merge pull request #7 from nigelrudolf/nigel-dev
Browse files Browse the repository at this point in the history
Updated atlas with animations
  • Loading branch information
nigelrudolf authored Aug 26, 2020
2 parents 681ba1e + 80a4af5 commit 0e2147a
Show file tree
Hide file tree
Showing 3 changed files with 268 additions and 72 deletions.
332 changes: 264 additions & 68 deletions assets/atlas.json
Original file line number Diff line number Diff line change
@@ -1,76 +1,272 @@
{
"frames": {
"curiosity-back-drive.000": {
"frame": {
"x": 1,
"y": 1,
"w": 48,
"h": 48
"textures": [
{
"image": "atlas-n.png",
"format": "RGBA8888",
"size": {
"w": 600,
"h": 50
},
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 48,
"h": 48
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 48,
"h": 48
}
},
"curiosity-back-drive.001": {
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 48,
"h": 48
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 48,
"h": 48
},
"frame": {
"x": 51,
"y": 1,
"w": 48,
"h": 48
}
},
"curiosity-back-drive.002": {
"frame": {
"x": 101,
"y": 1,
"w": 48,
"h": 48
},
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 48,
"h": 48
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 48,
"h": 48
}
"scale": 1,
"frames": [
{
"filename": "curiosity-back-drive.000",
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 48,
"h": 48
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 48,
"h": 48
},
"frame": {
"x": 1,
"y": 1,
"w": 48,
"h": 48
}
},
{
"filename": "curiosity-back-drive.001",
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 48,
"h": 48
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 48,
"h": 48
},
"frame": {
"x": 51,
"y": 1,
"w": 48,
"h": 48
}
},
{
"filename": "curiosity-back-drive.002",
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 48,
"h": 48
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 48,
"h": 48
},
"frame": {
"x": 101,
"y": 1,
"w": 48,
"h": 48
}
},
{
"filename": "curiosity-front-drive.000",
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 48,
"h": 48
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 48,
"h": 48
},
"frame": {
"x": 151,
"y": 1,
"w": 48,
"h": 48
}
},
{
"filename": "curiosity-front-drive.001",
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 48,
"h": 48
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 48,
"h": 48
},
"frame": {
"x": 201,
"y": 1,
"w": 48,
"h": 48
}
},
{
"filename": "curiosity-front-drive.002",
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 48,
"h": 48
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 48,
"h": 48
},
"frame": {
"x": 251,
"y": 1,
"w": 48,
"h": 48
}
},
{
"filename": "curiosity-left-drive.000",
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 48,
"h": 48
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 48,
"h": 48
},
"frame": {
"x": 301,
"y": 1,
"w": 48,
"h": 48
}
},
{
"filename": "curiosity-left-drive.001",
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 48,
"h": 48
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 48,
"h": 48
},
"frame": {
"x": 351,
"y": 1,
"w": 48,
"h": 48
}
},
{
"filename": "curiosity-left-drive.002",
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 48,
"h": 48
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 48,
"h": 48
},
"frame": {
"x": 401,
"y": 1,
"w": 48,
"h": 48
}
},
{
"filename": "curiosity-right-drive.000",
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 48,
"h": 48
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 48,
"h": 48
},
"frame": {
"x": 451,
"y": 1,
"w": 48,
"h": 48
}
},
{
"filename": "curiosity-right-drive.001",
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 48,
"h": 48
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 48,
"h": 48
},
"frame": {
"x": 501,
"y": 1,
"w": 48,
"h": 48
}
},
{
"filename": "curiosity-right-drive.002",
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 48,
"h": 48
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 48,
"h": 48
},
"frame": {
"x": 551,
"y": 1,
"w": 48,
"h": 48
}
}
]
}
},
],
"meta": {
"app": "https://www.codeandweb.com/texturepacker",
"version": "3.0",
"image": "atlas.png",
"format": "RGBA8888",
"size": {
"w": 150,
"h": 50
},
"scale": 1,
"smartupdate": "$TexturePacker:SmartUpdate:9530fc4aaaa628a69bd1e6db347a326c:81f7af523aff777a2955ac66cafca4e5:cbce6b53f0f49e0bf15173c25c41f876$"
"smartupdate": "$TexturePacker:SmartUpdate:52a817ce8c80b51407189fa84a9dfee5:110724a03ee43b73ca0f0918d5713502:157249cac142b4da00f88a46293cb2de$"
}
}
Binary file modified assets/atlas.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ anims.create({

function update () {

const speed = 500;
const speed = 50;
const prevVelocity = player.body.velocity.clone();

// Stop any previous movement from the last frame
Expand All @@ -148,13 +148,13 @@ function update () {

// Update the animation last and give left/right animations precedence over up/down animations
if (cursors.left.isDown) {
player.anims.play("curiosity-back-drive", true);
player.anims.play("curiosity-left-drive", true);
} else if (cursors.right.isDown) {
player.anims.play("curiosity-back-drive", true);
player.anims.play("curiosity-right-drive", true);
} else if (cursors.up.isDown) {
player.anims.play("curiosity-back-drive", true);
} else if (cursors.down.isDown) {
player.anims.play("curiosity-back-drive", true);
player.anims.play("curiosity-front-drive", true);
} else {
player.anims.stop();

Expand Down

0 comments on commit 0e2147a

Please sign in to comment.