Emitter or Particle Tutorial?

Ah, just what I hoped to hear (“waterDisplayGroup”). While you can’t make a particle emitter “isometric” by its own nature, you could make it emit particles like blurred circles/squares or wavy textures which are made isometric in Photoshop or whatever. And then you could emit them across a large rectangular area in the water display group, and have each particle undergo a subtle motion or up-and-down scaling to provide at least some level of “waves in ocean”.

I’d have to tinker around with the concept using Particle Designer to see how far I can get, or how realistic it might look, but it’s certainly worth a shot.

I did have this working and it did give a watery effect but it was a massive performance hit on all but s7 level devices so I removed it

function addWater() waterDisplayGroup:scale(1,0.5) waterDisplayGroup.y = \_tileH/2 -- Create container for visual objects, width is sine 45 deg = 0.704 local containerWidth = \_tileW \* (\_maxTilesX - 1) \* 0.704 local waterWidth = containerWidth + 100 local water1 = display.newRect( 0, 0, waterWidth, waterWidth ) waterDisplayGroup:insert( water1 ) water1.rotation = 45 local water2 = display.newRect( 0, 0, waterWidth, waterWidth ) waterDisplayGroup:insert( water2 ) water2.rotation = 45 -- Set defaults for repeated textures which follow display.setDefault( "textureWrapX", "repeat" ) display.setDefault( "textureWrapY", "mirroredRepeat" ) -- Apply repeating textures and filters to objects water2.fill = { type="image", filename="images/water-fill.png" } water2.fill.scaleX = 0.01 water2.fill.scaleY = water2.fill.scaleX water2.fill.rotation = 15 water2.alpha = 0.4 if \_dayOrNight ~= "day/" then water2:setFillColor(0.3,0.3,0.3,1) end water1.fill = { type="image", filename="images/water-fill.png" } water1.fill.scaleX = 0.01 water1.fill.scaleY = water1.fill.scaleX water1.fill.rotation = -10 water1.alpha = 0.9 if \_dayOrNight ~= "day/" then water1:setFillColor(0.3,0.3,0.3,1) end water1.fill.effect = "filter.wobble" water1.fill.effect.amplitude = water1.fill.scaleX \* 2 water2.fill.effect = "filter.wobble" water2.fill.effect.amplitude = water2.fill.scaleX \* 2 -- Set defaults for repeated textures which follow display.setDefault( "textureWrapX", "clampToEdge" ) display.setDefault( "textureWrapY", "clampToEdge" ) -- Begin repeating transition function local function repeatTrans() transition.to( water1.fill, { time=4000, x=water1.fill.x+0.5, onComplete=repeatTrans }) transition.to( water2.fill, { time=4000, x=water1.fill.x+0.5 }) if ( water1.alpha == 0.9 ) then transition.to( water1, { time=3000, alpha=1, transition=easing.inOutQuad } ) transition.to( water2, { time=3600, alpha=0.6, transition=easing.inOutQuad } ) else transition.to( water1, { time=3000, alpha=0.8, transition=easing.inOutQuad } ) transition.to( water2, { time=3600, alpha=0.4, transition=easing.inOutQuad } ) end end repeatTrans() end

Do bear in mind my display group is 9,360x4,680px so I hit lots of limitations on rendering speed - what Perry and Vlad are currently looking into.

Oh yes, the “wobble” filter is cool… but it can be a beast of performance, and at the size you mention, I’m not surprised.

Have you ever checked out the “PatternFill” sample in the SampleCode > Graphics folder? That’s a demo I created awhile back which IIRC uses just 2 semi-opaque water textures, animating atop each other. Perhaps you could do something like that, just adjusted to be isometric by using quadrilateral distortion of the x1,y1-x4,y4 points.

Brent

Hmmm… scratch that… the demo uses the wobble filter, lol. But maybe you could just transition the elements around without the wobble and still get a nice effect.

I just checked that and it is spookily very similar to my posted code (I think it was from a post somewhere).  But unfortunatly that uses wobble too! 

When you apply _displayGroup:scale(1,0.5)_on the size I use it dies a death on devices.  The hit was well over 10 fps.

I’m really hoping you can work some magic with particle emitters as standard Corona code just doesn’t scale on the size I need.

Hope you like a challenge! :wink:

I think animating the water tiles themselves (IE cycling through a set of images) is your best bet.

It depends entirely on how you have your map and images set up though.

For example, is your water layer using individual images per tile, or frames from an imagesheet per tile?

That would let you know whether you had to do it manually or could use an animated sprite.

Also, whether you cull the tiles offscreen manually or not could determine what approach might be fastest.

In fact, if water is your base layer, it wouldn’t even need tiles, it could just be a single image that has a texture repeating over it of the same size as the tile, which means you could either:

  • Cycle through a series of fullscreen images or

  • Set up a rect that is fullscreen and fill it with the tiled image, and then cycle that image and change the fill offset to animate.

Much depends on how you are actually drawing the screen though, so I’d need more info to be able to help.

Hi rakoonic,each water tile is individual (and is a frame on an imagesheet with all the other ground textures.  Off screen tiles are culled manually in code.

I did try having the water as a single 960 x 1600 image (and also tried animating it with wobble filters) it but it looked weird when the ground moved but the water didn’t.  Also it didn’t scale well when the game is pinch zoomed.  So I settled on individual static tiles.

Try Google… https://github.com/vsergeyev/Rain/blob/master/Rain/rain.lua

Well I did try just bouncing up and down in front of the monitor singing the happy song but in the end I did use google.

I found that site. The code is outdated and I couldnt get it to function.

lol!!!   BTW, the code works fine and I use it in my app

Hi @Atrag,

Particle emitters are pretty easy to configure. Probably the best place to begin (for free) is to download our “EmitterViewer” sample project (it’s also bundled with the Corona application within SampleCode>Graphics).

https://github.com/coronalabs/samples-coronasdk/tree/master/Graphics/EmitterViewer

This sample contains a wide variety of emitters which are controlled by their respective JSON configuration files. If you find one you like, you can modify its behavior according to our EmitterObject documentation, adjusting values in the JSON file until you get the effect you like.

https://docs.coronalabs.com/api/type/EmitterObject/index.html

Hope this helps,

Brent

@Brent… Replicating rain is difficult in a particle emitter, I did try.  Particle emitters work great for source point animation like fires, etc. But they are not good for ambient weather effects which would need many hundreds of emitters as speed becomes a real issue.

Although if you have an example that can produce ambient weather effects I would be interested to see!

For example rain falling from a cloud? I would just “spread out” the emitter into a line/field emitter (not point) and then have drops falling randomly from it.

Wait… there are emitter types that aren’t point?  Oh that’s new…  goes of to investigate this.

@Brent again, I missed the memo.  Wish you guys would shout louder about new features!

Well, it’s sort of the same thing in that the emitter is “located at a point”. However, you can just tell the emitter to spread out any distance along the X or Y access from its location, and particles will start emitting from anywhere within that line or rectangular region. This is how people create particle effects like waterfalls.

Brent

Now if there was some way to create an isometric water effect - like an ocean mesh in Unity - I would be ecstatic!  I’ve tried and failed… Well, it worked great but not on device as it killed the frame rate.

Can you show me an example of what you mean? I might have some ideas (no guarantee, but I can at least see what you would like).

Thanks for your help… I will take a look at what you both suggested. Really all I want is a few cartoony droplets coming down from a moving rain cloud and the droplets impulsing whatever they collide with.

BTW, the code works fine and I use it in my app

It is the main.lua that didn’t work last time I tried it it seems. I guess I will adapt it to my own and see what it does. Guess I should sleep first though. Good night!

Ah… be aware @Atrag… built-in emitters are for visual effects, not for collision events like impulsing things the particles collide with. You may be able to use a third-party like “CBEffects” to actually add physical bodies to particles and then detect collisions on them. The library hasn’t been updated in awhile, but it was very popular back in the day and it should still work nicely:

https://github.com/GymbylCoding/CBEffects

Brent