Anim8: Vote your preferred flip method syntax

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.

What flipping animation syntax do you fancy?

a1
0
No votes
a2
4
27%
a3
3
20%
a4
8
53%
other (please comment)
0
No votes
 
Total votes: 15

User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Anim8: Vote your preferred flip method syntax

Post by kikito »

Hi there,

Some days ago someone mentioned his desire to have a way to "flip" animations in anim8. So, for example, if you have a walking animation of someone moving to the left, you could generate the walking to the right animation from it with a single command, reusing the image.

I like this, because it would make code smaller and also save some memory.

What I need is to find a good API to do that.

So far I've come up with the following alternatives:

Code: Select all

    local a = anim8.newAnimation(...)

    local a1 = anim8.flipH(a) -- vertical: anim8.flipV(a)
    local a2 = anim8.flip('h', a) -- vertical: anim8.flip('v', a)
    local a3 = a:flip('h') -- or a:flip('v')
    local a4 = a:flipH() -- or a:flipV() 
I've got a favourite one, but I'd like to hear what you think. Please vote the syntax you'd rather have.
Last edited by kikito on Mon Dec 03, 2012 10:49 pm, edited 1 time in total.
When I write def I mean function.
Santos
Party member
Posts: 384
Joined: Sat Oct 22, 2011 7:37 am

Re: Anim8: Vote your preferred flip method syntax

Post by Santos »

Hmmmmmmmm...

Methods seem nice, and a4 is cool because it doesn't use constants and you can also do this:

Code: Select all

a:flipH():flipV()
But then again... with a3, it could be like the __mode of metatables, and you could use words with "h" and "v" in them if you wanted to flip it both ways.

Code: Select all

a:flip('valhalla')
a:flipX() and a:flipY() could work too I think.

a:flip(false, true) would be consistent with Quad:flip, buuut it's a bit hard to tell what's going on with that method.

Alternatively, you could just use skateboarding tricks.

Code: Select all

a:kickflip()
Then you could feel like you're playing Tony Hawk's Pro Skater.

I am unsure.
User avatar
Dattorz
Citizen
Posts: 66
Joined: Sat Oct 27, 2012 12:32 am
Contact:

Re: Anim8: Vote your preferred flip method syntax

Post by Dattorz »

I'm not a fan of having the flip() function do a toggle. Personally I think you should be able to pass a truth value that says whether or not you want the sprite flipped in that direction (this is how I'm doing it in my framework currently). It's easier to keep track of things this way - you don't need to know what the current flipped state is, you just tell it what you want it to be.
User avatar
Inny
Party member
Posts: 652
Joined: Fri Jan 30, 2009 3:41 am
Location: New York

Re: Anim8: Vote your preferred flip method syntax

Post by Inny »

I haven't used anim8, but here's a question about one of the API functions:

Code: Select all

Animation:draw(image, x,y, angle, sx, sy, ox, oy)
Wouldn't supplying negative values in the sx and sy parameters already be enough to perform the flipping?
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Anim8: Vote your preferred flip method syntax

Post by kikito »

Inny wrote:I haven't used anim8, but here's a question about one of the API functions:

Code: Select all

Animation:draw(image, x,y, angle, sx, sy, ox, oy)
Wouldn't supplying negative values in the sx and sy parameters already be enough to perform the flipping?
Yes, but it's not a comfortable way of doing it. When flipping, both the scale and the offset have to be set. The scale is not too bad (-1 or 1 on each param) but the offset is a bit of a pain (-frameWidth or 0). Plus, if you want to be able to draw flipped animations with scale/offset, you have to be multiplying those values. I would make those calculations inside anim8.
Dattorz wrote:I'm not a fan of having the flip() function do a toggle. Personally I think you should be able to pass a truth value that says whether or not you want the sprite flipped in that direction (this is how I'm doing it in my framework currently). It's easier to keep track of things this way - you don't need to know what the current flipped state is, you just tell it what you want it to be.
I'm not sure I understand. None of the methods I described does "a toggle", they create a new animation. If this is not clear, I might need to change the names a bit more.

@santos: I liked most of your suggestions, thanks. FlipX and flipY sound nice. I agree that using 2 booleans is a bit confusing, and I'd rather avoid it.
When I write def I mean function.
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Anim8: Vote your preferred flip method syntax

Post by Nixola »

I'd prefer a1 and/or a3 (maybe a3), but I don't use Anim8 (I don't like to use external libraries or modules)
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Anim8: Vote your preferred flip method syntax

Post by Robin »

a4, without a doubt.

EDIT: I did not realise this was a poll topic (the poll got pushed off my screen), so please disregard my post.
Last edited by Robin on Mon Dec 03, 2012 8:54 pm, edited 1 time in total.
Help us help you: attach a .love.
User avatar
Puzzlem00n
Party member
Posts: 171
Joined: Fri Apr 06, 2012 8:49 pm
Contact:

Re: Anim8: Vote your preferred flip method syntax

Post by Puzzlem00n »

a2 is kinda cool, but I feel a4 is a bit more flexible, so I'm going with that.

Thanks for putting this feature in, by the way, should be really helpful. Oh, and not to nag you, but you have a little typo in the vertical parts of the a1 and a2 examples. ;)
I LÖVE, therefore I am.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Anim8: Vote your preferred flip method syntax

Post by kikito »

Robin wrote:a4, without a doubt.

EDIT: I did not realise this was a poll topic (the poll got pushed off my screen), so please disregard my post.
Ah, but your commend provided some useful info. Some people voted for one option, but declared that they really didn't feel too strongly about it. You, on the other hand, chose a2 'without a doubt'. That is significant. May I ask why?

@Puzzledm00n, thanks, I've fixed the typos.
When I write def I mean function.
User avatar
Garan
Prole
Posts: 17
Joined: Tue May 01, 2012 2:37 am

Re: Anim8: Vote your preferred flip method syntax

Post by Garan »

Hey cool, my question is getting new stuff added!
Anyway: I think of the choices a4 is the best, as it can easily just inserted into movement commands and the like. However, I was thinking something that might be a good idea would be a setDirection (or setXDirection and setYDirection) instead of a flipH() and flipY(). If you just have a flip like that, you might end up flipping twice when only once was needed. I was also wondering if there could be an optional parameter in anim8:draw that says which direction to draw. That way I can keep using my direction variables.
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests