Skip to content
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

Improve animation support in fromLibGdx() #2278

Merged
merged 7 commits into from
Feb 27, 2021
Merged

Conversation

Descrout
Copy link
Contributor

@Descrout Descrout commented Nov 30, 2020

Get the image index in the atlas, if its not -1, this means the image is a part of an animation. Add _$index suffix to name so it can be used by animation.addByPrefix.

Example

Code:

var frames = FlxAtlasFrames.fromLibGdx(AssetPaths.myAtlas__png, AssetPaths.myAtlas__atlas);
var player = new FlxSprite();
player.frames = frames;
player.animation.addByPrefix("idle", "adventurer-idle", 12);
player.animation.addByPrefix("crouch", "adventurer-crouch", 12);
player.animation.play("idle");

myAtlas.atlas :

myAtlas.png
size: 2048,512
format: RGBA8888
filter: Nearest,Nearest
repeat: none
adventurer-idle
  rotate: false
  xy: 324, 51
  size: 50, 37
  orig: 50, 37
  offset: 0, 0
  index: 2
adventurer-idle
  rotate: false
  xy: 568, 53
  size: 50, 37
  orig: 50, 37
  offset: 0, 0
  index: 0
adventurer-idle
  rotate: false
  xy: 1974, 391
  size: 50, 37
  orig: 50, 37
  offset: 0, 0
  index: 1
adventurer-crouch
  rotate: false
  xy: 1981, 430
  size: 50, 37
  orig: 50, 37
  offset: 0, 0
  index: 2
adventurer-crouch
  rotate: false
  xy: 1870, 391
  size: 50, 37
  orig: 50, 37
  offset: 0, 0
  index: 0
adventurer-crouch
  rotate: false
  xy: 1922, 391
  size: 50, 37
  orig: 50, 37
  offset: 0, 0
  index: 1

Get the image index in the atlas, if its not -1, this means the image is a part of a list(animation). Add '_$index' suffix to name so it can be used by 'animation.addByPrefix'.
@Descrout Descrout requested a review from Gama11 November 30, 2020 15:01
`getDimensions` returns anonymous `{x:Int, y:Int}` struct instead of array.
@Gama11 Gama11 changed the title Update fromLibGdx() Improve animation support in fromLibGdx() Feb 27, 2021
@Gama11 Gama11 merged commit 6390bc0 into HaxeFlixel:dev Feb 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants