ID:1668097
 
Keywords: effects, visual
(See the best response by Kaiochao.)


Problem description:

What is the best way to do visual effects?

Like I want to spawn a magic shield on a player that last for 5 seconds. Then deletes.

Should i spawn an object and then attach it to the player?

Should I just add and overlay to the player for a few seconds?

Should I have a default 'effects' overlay that i should flick?

I am trying to figure out what is the best way to handle this. Any advice would be appreciated.
The original question is about visual effects, but the rest of the post talks about overlays and overlay-like objects, but that's only one small part of the topic of visual effects.

In the case of your magic shield overlay:

1. It's not possible to flick() an overlay, so you'd have to spawn an object if you want to use flick(). Forum_account's Overlays library handles this well enough and you might learn something from the rest of the library.

2. If you're not trying to flick() an icon_state, then you should use an overlay.

3. I don't know what "default 'effects' overlay" means.

In response to Kaiochao
Hmm perhaps visual effects was bad wording.

I guess the correct question would be. If i want to use a spell and display an animation. Do I have to spawn an object every single time. Even though the object itself will just be deleting within a few moments?

Is there a better tool other than objects that would handle this. (understand that these spawns objects would have no other interaction just purely for animation effects.)
You can create an image and have it do exactly what you want. Look it up in the reference and mess around with it :)
In response to Mouchy
You don't have to spawn an object every single time. You can, if you want to, and it'll be a while (if ever) before you encounter any performance issues from it.

Another option would be to use an object pool, where you create objects only when necessary, and generally never actually delete them. After the animation is displayed, the object should be removed from the map or overlays, but added to a list ("pool") of inactive effect objects. When you want to display an animation, pick an object from the pool, or if the pool is empty, create a new object.
In response to MDC
Nail on the head thank you. This was what I was missing. I dont know how I forgot about images.
In response to Kaiochao
Ah smart idea I will consider this. Could I do the same idea with a pool of images.
In response to Mouchy
Best response
You can use a pool for any object that you can create and modify, so yes, but as an overlay, an /image won't be affected by flick().

If you don't need flick():

An advantage of overlays is that if you don't plan on modifying an overlay, you can reuse it by adding the same overlay object to multiple overlays lists.

You might not even need to create any objects, since you could just add a type path to overlays.


With those in mind, you might not even need to bother with an object pool.
Alright thanks guys I think I have it sorted out now.