How to [store_unit], kill, [unstore_unit] with fade out/in?

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
User avatar
Simons Mith
Posts: 821
Joined: January 27th, 2005, 10:46 pm
Location: Twickenham
Contact:

How to [store_unit], kill, [unstore_unit] with fade out/in?

Post by Simons Mith »

I'm using store_unit with kill=yes and a delay to make a unit briefly disappear then reappear after about 0.7 seconds with some changes. Works fine, but the unit disappears and reappears abruptly. Is there a neat way to fade a unit in and out at about recruitment speed? For the fadeout I can't use kill+animate because the unit has a die animation and I don't want her to actually 'die'.
 
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Re: How to [store_unit], kill, [unstore_unit] with fade out/

Post by Sapient »

Well the obvious way would be to use http://wiki.wesnoth.org/ImagePathFuncti ... g_function
and change opacity of a unit image in a loop.

However the more correct way would probably be
using an [effect] to add a [new_animation] (which allows the full AnimationWML syntax to be used, e.g. highlight=1~0:600,0~1:600) then trigger it with [animate_unit]
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
User avatar
Simons Mith
Posts: 821
Joined: January 27th, 2005, 10:46 pm
Location: Twickenham
Contact:

Re: How to [store_unit], kill, [unstore_unit] with fade out/

Post by Simons Mith »

Darn, I was hoping there was a lazy way. Thanks.

But one other question: what exactly is the 'highlight'=1~0:600 tag? I've tried it (in several combinations) and it seems to do nothing. It's referred to twice on that Wiki page, but it's not listed or explained in any of the syntax summaries.

Edit: Another question arises: why in the name of all that's arcane does this code cause my mage to float upside-down??

Code: Select all

[object]
id=fade_in
silent=yes
[filter]
id=Wiowen
[/filter]
[effect]
apply_to=new_animation
[animation]
fade_in_start_time=0
[fade_in_frame]
duration=1
image="misc/blank-hex.png"
[/fade_in_frame]
[fade_in_frame]
duration=600
highlight=1~0:600
image="units/human-magi/mage+female.png"
[/fade_in_frame]
[/animation]
[/effect]
[/object]
mini-bump (merged double-post) - is this a bug? Even if there is an error in that code, I'm mystified as to how anything in it could cause a unit to turn upside down. The behaviour appears identical if you replace highlight with alpha.
Attachments
Every time she moves downwards she flips vertically. Also her movement is very jerky.
Every time she moves downwards she flips vertically. Also her movement is very jerky.
Upsidedown.png (68.06 KiB) Viewed 1684 times
Last edited by Simons Mith on November 19th, 2011, 4:53 am, edited 1 time in total.
 
User avatar
Simons Mith
Posts: 821
Joined: January 27th, 2005, 10:46 pm
Location: Twickenham
Contact:

Re: How to [store_unit], kill, [unstore_unit] with fade out/

Post by Simons Mith »

mini-bump (will merge this double-post later) - is this a bug? Even if there is an error in that code, I'm mystified as to how anything in it could cause a unit to turn upside down. The behaviour appears identical if you replace highlight with alpha.

Edit: Ack! I thought I /could/ merge my own posts, and/or delete the second one. But if I can, I don't see where you do it.
Last edited by Simons Mith on November 19th, 2011, 4:56 am, edited 1 time in total.
 
User avatar
Pentarctagon
Project Manager
Posts: 5564
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: How to [store_unit], kill, [unstore_unit] with fade out/

Post by Pentarctagon »

I don't know, but if it isn't you should keep it. Might be useful as a starting point if you wanted to make a unit spin in place or something :lol2: .
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
User avatar
Simons Mith
Posts: 821
Joined: January 27th, 2005, 10:46 pm
Location: Twickenham
Contact:

Re: How to [store_unit], kill, [unstore_unit] with fade out/

Post by Simons Mith »

Some progress. The unwanted unit inversion appears to be due to something absent from the code above:
the new 1.9 auto_vflip= tag must be added and set to no, as it seems to default to yes.

What is this tag actually intended for, and shouldn't it default to no? So that not having it present at all doesn't introduce unexpected behaviour? auto-flipping left/right seems more reasonable, but for up/down aren't there likely to be more cases where you have to turn the feature off than leave it alone?
I actually had to add dev WML code to turn off a feature I didn't know about before my girl stopped randomly standing on her head! For that reason I think auto-vflip and auto-hflip should be no by default.

I've also tried applying fade-in/fade-out to a unit's move animation, and the result was a partially-cloaked Sword Drake swooping across the map. But the same code applied to a stationary unit still has no visible effect!
 
Post Reply