Animation Not Found?
-
I've been following a small little tutorial series on HaxeFlixel by GamesFromScratch, and when I tried following his one on animation, whenever I run the game it says that my animation is not found.
Here is the tutorial I'm following: https://www.youtube.com/watch?v=6A7c5gD-xyU&index=8&list=PLS9MbmO_ssyBcgdfrd4beEUeQtsdvM2st
Please note that I am using HaxeDevelop for the project, and I am testing the windows target, if that makes any difference.
-
I watched some of the video but it's too long to find where the code that might be a problem is. Can you post the code you have in the project where you add the animation? It will help.
Here's some code that might help.
// loadGraphic() function - make sure you have Animated (2nd parameter) set to true. // Also, if graphic doesn't have square frames, add the width and height of the (one) frame size. loadGraphic("assets/images/my_sprite_sheet.png", true, 16, 24); // add the animations with the frames array to use from the spritesheet. // make sure the graphic has the frames you're specifying, meaning they exist. The frames array starts with 0. animation.add("idle", [0], 30, true); animation.add("walking", [1, 2, 3, 4], 30, true); // start out idle. animation.play("idle");
-
@dean Alright, here's the code:
spritesheet = new FlxSprite(); spritesheet.loadGraphic(AssetPaths.walkingDude__png, true, 512, 384); spritesheet.animation.add("right",[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],5,true); spritesheet.animation.play("right");
-
@edmanbosch
IswalkingDude.png
in your assets folder?
-
@dean Yes, in the "images" folder inside of it.
-
Do you have this class in your source?
AssetPaths.hx
package; @:build(flixel.system.FlxAssets.buildFileReferences("assets", true)) class AssetPaths {}
-
@dean Yes I do. Everything works fine if I just load the image onto the sprite and add it to the game, but everything breaks when I try to add animation.
-
hmm. not sure what's wrong. I might not be of much help with this.
What versions of openFL and Lime are you using? Should be:
openfl: [3.6.1]
lime: [2.6.1]oops
lime: [2.9.1]Does it work if targeting flash?
One more thing, make sure you don't have a typo with the animation name :) sometimes it's the little things.
-
@dean I'm not sure how to check OpenFL and Lime versions? I'm currently looking for someway to test on flash, so I'll see if that works.
-
@edmanbosch
from command prompt type:haxelib list
and it lists all libs with current versions in[ ]
To install a different version, usehaxelib install openfl 3.6.1
You can change to another (installed) version with set.haxelib set openfl 3.6.1
-
The walkingDude graphic should be 1024 x 768. Maybe you copied the small graphic from the tut? Sorry, I'm running out of ideas.
-
@dean Alright, well my Lime and OpenFL versions seem to be fine, although Lime is version 2.9.1 instead of 2.6.1?
I fixed the issue though, it seems like it was because I downloaded the smaller sprite. Thanks for the help.
-
@edmanbosch
oops, my bad on that, you're right. lime should be 2.9.1
-
Glad you got it working!
-
Now it shows the entire sheet, instead of only showing a sub image, it's weird.
-
ok, when you update an asset with the same name, the build will use the old one unless you do a clean build. To get it to use the new one, delete the export folder and build again. Try that.
EDIT: If you have trouble deleting the folder due to permissions, you might need to close HaxeDevelop, then delete it.
-
@dean It still shows the same thing.
Why would displaying the entire thing be caused by it using the old one? I'm pretty sure it shows part of the sprite sheet is because I set the frame size incorrectly.
-
@edmanbosch
The old graphic (small one) is 240 x 181 and each frame of the big one is larger than that, so it will show the whole small one.You deleted the export folder and rebuilt with the new 1024 x 768 walkingDude.png?
-
@dean Yeah, it appears the problem was because of the frame size. The tutorial gave an incorrect frame size, which caused many issues.
-
ah, yes. 256 x 192 frame size. Well that was something you wouldn't have expected with the tutorial.