-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Animations in code #22
Comments
I've added a flag in the latest release to enable/disable animations on a per-tile/object basis: tile.enableAnimation = true
object.enableAnimation = false Due to changes in the last release, SpriteKit actions weren't always being created for tile objects, but this should fix it. |
Thanks, but I am still not sure how I actually go about changing the animation in code. |
Gotcha. So you're looking for a way to manually set the tile data (ie texture/animation) for a tile object? |
Yes exactly. I have a character (tile object) with multiple animations inside a tileset that I want to be able to change between, but I don't know how I could manually change the tile data in code. Is there a way to do that right now? |
There is no way to do that currently, unfortunately. I'll roll that functionality into the next update, but it might not solve your problem as changing the tile data on an object repeatedly to animate it will likely result in a loss of performance. You might have better luck extracting animation data directly from your tilesets and stashing them onto an AnimationComponent (or some structure you've created for game entities) for quick access. There are two ways to go about that now, the first is via the // extract tile animation as a SpriteKit action
if let walkLeftData = tileset.getTileData(named: "walk-left") {
let walkLeftAction = walkLeftData.animationAction
sprite.run(walkLeftAction)
} Personally, I've had a lot of luck setting up characters with entity/component systems with GameplayKit, using the I should have an update out early next week, hope that helps. |
Hi, how would I go about animating a SKTileObject in code?
The animations exist within the object's tileset, but the object is not animated to begin with.
Do I manually need to create SKActions or do I change the tileData ID somehow?
The text was updated successfully, but these errors were encountered: