Using smoke cloud to hide an object

Hi,

I'm trying to use a modified version of the light/dark smoke cloud to hide a object in my game. Basically, I need the cloud to appear and quickly cover the 18x18 block. It should fade out pretty quickly, with the block being removed once completely covered.

I've managed to get something like this, but configuring the cloud is tricky. The explanations of the properties of particles don't help either, eg: "Scale-in speed: The scale in speed" is not a helpful piece of documentation.

Here's my cloud - could someone explain how to modify it so that it appears quickly, animates and disappears almost as quickly as it appeared, all within 1 second, please?

Many thanks,

Matt.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
        Particles.CreateParticleType ("HeavySmokeBright",
                {
                imagePath                       = "smoke_heavy_bright.png",
--              imageWidth                      = 64,   
--              imageHeight                     = 64,
                weight                          = 0,
                directionVariation      = 45,   
--              velocityVariation       = 25,
                rotationVariation       = 360,
                rotationChange          = 30,
                useEmitterRotation      = false,
                alphaStart                      = 0.0,
                fadeInSpeed                     = 1.5,
                fadeOutSpeed            = -1.5,
                fadeOutDelay            = 500,
--              scaleStart                      = 0.1,
                scaleVariation          = 0.1,
                scaleInSpeed            = 0.1,
                emissionShape           = 0,
                emissionRadius          = 10,
                killOutsideScreen       = true  ,
                lifeTime                        = 1000  
                } )
        
        Particles.CreateParticleType ("HeavySmokeDark",
                {
                imagePath                       = "smoke_heavy_dark.png",
--              imageWidth                      = 64,   
--              imageHeight                     = 64,
                weight                          = 0,
                directionVariation      = 45,   
--              velocityVariation       = 25,
                rotationVariation       = 360,
                rotationChange          = 30,
                useEmitterRotation      = false,
                alphaStart                      = 0.0,
                fadeInSpeed                     = 1.5,
                fadeOutSpeed            = -1.5,
                fadeOutDelay            = 500,
--              scaleStart                      = 0.1,
                scaleVariation          = 0.1,
                scaleInSpeed            = 0.1,
                emissionShape           = 0,
                emissionRadius          = 10,
                killOutsideScreen       = true  ,
                lifeTime                        = 1000  
                } )
 
        local emitname = system.getTimer()..x..y
        Particles.CreateEmitter(emitname, x, y, 0, false, false, true)
        Particles.AttachParticleType(emitname, "HeavySmokeBright", 3, 500,0)
        Particles.AttachParticleType(emitname, "HeavySmokeDark"  , 3, 500,0)
        Particles.StartEmitter( emitname )

The reference says "The scale-in speed (within one second)". So it's clear that, when using 2.0 as a scale-in speed, for example, the particle will be twice as big within a time frame of one second. This is also documented in all included sample codes (see comments there).

If scaleStart is set to 0.1 (almost invisible) and you want the particles to be scaled to normal size (1.0) within a second, just use 1.0 as scaleInSpeed. Same with the scaleOutSpeed parameter, except that scale out will start after the scaleOutDelay has passed.

Also the same with the fade parameters.

To let a particle fade-in qickly and let is disappear again after one second, you could use:

1
2
3
4
alphaStart      = 0             
fadeInSpeed     = 2.0   
fadeOutSpeed    = -2.0  
fadeOutDelay    = 500   

I read 'scaleInSpeed' to be a speed rather than a scale. To be consistent with the rest of the API I would have expected them to be called 'scaleInStart' and 'scaleInEnd' or something of that ilk.

What I'd ideally like is for the scale in to happen within .1 seconds, have the animation continue for .7 seconds, then scale out in the remaining .2 seconds.

If I understand your post correctly, that's not possible?

matt

I am not sure what you mean with "animation" since you can animate many parameters of a particle (scale, alpha, frame, rotation etc.), but if I understood you correctly, you'd like to scale a particle, then stop scaling for a while, then let it shrink again.

If so, this would require a "maxScale" parameter to stop scaling of a particle once it reaches a certain scale. This could be added with the next update.

Yes, that's it.

And I just noticed your username...

Thanks for the promote help and yes, finer control (at least in my, rather pedantic, case) is needed I suppose.

Matt

views:1398 update:2011/10/14 9:11:21
corona forums © 2003-2011