A Particle System on an object.

Started by Calin Leafshade, Fri 27/11/2009 17:06:29

Previous topic - Next topic

Calin Leafshade

Is it possible to animate an object using a dynamic sprite?

I planned to use an object at (0,240) to draw to so that the particles were always on top of everything else but for some reason it just doesnt seem to want to update in rep_ex.

Gilbert

Do you Release() the DrawingSurface in each game loop? After drawing to one you need to Release() it to update it.

Calin Leafshade

#2
heh oh yeah.. idiot.

thanks  ;D

Edit:

I can draw things to the dynamic sprite/object fine unless i try to make the particles transparent.. do Objects support Alpha channels?

GarageGothic

Objects do support alpha channels, but DrawingSurface does not (or rather, you can draw alpha channel sprites to a surface, but if the surface is blank the "magic pink" color will show through). If you need the particles to be transparent the only current solution is to draw opaque objects to the surface and set the transparency of the object instead - so no true alpha channel, sorry.

Ryan Timothy B

This post is getting slightly old, but I'm basically doing the same thing.  After reading what GG said, what is the purpose of the optional bool hasAlphaChannel in the DynamicSprite.Create?

I've tried to create the sprite with the hasAlphaChannel set as true, and tried drawing sprites with alpha channels to it.  But they never show up.  The only way they show up is if the sprite doesn't have an alpha channel.  I'm also not drawing with transparency, which I know is definitely not supported.

How does everyone make rain effects and such when I can't even seem to be able to create a sprite and draw alpha channeled sprites to it?  Am I doing something wrong?

Code: ags

DynamicSprite* particleSprite;
//sprite variable


function room_RepExec()
{
  if (particle_count>0) {
    particleSprite = DynamicSprite.Create(200, 200, true);
    DrawingSurface *surface = particleSprite.GetDrawingSurface();
    int i;
    while (i<particle_count) {
      surface.DrawImage(p[i].x, p[i].y, 14);
      i++;
    }
    surface.Release();
    oDustParticles.Graphic=particleSprite.Graphic;
  }
}


Or is it seriously not possible to draw an alpha channeled sprite onto a created sprite?
Obviously the other solution is to draw them as solid pixels and just set the object's transparency.

Calin Leafshade

yup, you simply cant draw with an alpha channel because the drawing surfaces cant blend alpha channels.

The only reason it works on the background is because the background has no alpha channel so you dont have to blend 2 alphas together.

As for how to do rain I suggest taking a look at the plugin...

or wait until May 1st.  :P

Ryan Timothy B

What's happening on May 1st?  A new AGS release with this supported?

Honestly though, I'd love for this to be answered: what is the purpose of the optional bool hasAlphaChannel in the DynamicSprite.Create if it doesn't seem to do anything?

Calin Leafshade

Mags ends on may the 1st.

Dynamic sprites DO support alpha channels (just like any other sprite in AGS) but the drawing surface doesnt support alpha blending so you cant draw sprites to it which require alpha blending.. so im not entirely sure what the point of being able to have a new blank dynamic sprite with an alpha channel if you cant draw to it with an alpha channel...

unless its just inheriting that behaviour from the .CreateFromExistingSprite function in which it DOES have a purpose since it takes the alpha channel from the existing sprite.

Ryan Timothy B

QuoteMags ends on may the 1st.
Ahh, I've heard about your pre-rendered effects -- if that's what you're referring to.  Definitely not the route I enjoy going, it's all about the programming fun for me.

Dualnames

Quote from: Calin Leafshade on Wed 28/04/2010 21:11:48
Mags ends on may the 1st.

Dynamic sprites DO support alpha channels (just like any other sprite in AGS) but the drawing surface doesnt support alpha blending so you cant draw sprites to it which require alpha blending.. soI'm not entirely sure what the point of being able to have a new blank dynamic sprite with an alpha channel if you cant draw to it with an alpha channel...

unless its just inheriting that behaviour from the .CreateFromExistingSprite function in which it DOES have a purpose since it takes the alpha channel from the existing sprite.

You're not gonna win you know..you broke that rule. ;D
Seriously I'd love to see what you came up with. So help him out folks. Few days left.

Quote from: Calin Leafshade on Wed 28/04/2010 21:11:48
Dynamic sprites DO support alpha channels (just like any other sprite in AGS) but the drawing surface doesnt support alpha blending so you cant draw sprites to it which require alpha blending.. soI'm not entirely sure what the point of being able to have a new blank dynamic sprite with an alpha channel if you cant draw to it with an alpha channel...

unless its just inheriting that behaviour from the .CreateFromExistingSprite function in which it DOES have a purpose since it takes the alpha channel from the existing sprite.

It's very useful when you just need the sprite.Graphic property for various stuff, it just doesn't really work with Surfaces that's all. People just love those. (:P)
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

SMF spam blocked by CleanTalk