Trouble with display.newEmitter( )

Hi All,

I’ve been having some issues with display.newEmitter( ) and need some help!

My goal is to use display.newEmitter( ) to emulate confetti when beating a game level.

Everything is up and working except one small aspect – the underlying image is transparent and I can’t make it opaque! (I do NOT want it to be transparent)

Please see the attached image (“screenshot.jpg”) below to get a better understanding of what I am experiencing.

Here is the code:

main.lua

local json = require("json") local cx, cy = display.contentCenterX, display.contentCenterY local myImage = display.newImage("landscape.jpg", cx, cy) myImage.width = 320 myImage.height = 480 local function loadParams(filename) local path = system.pathForFile(filename) local file = io.open(path, "r") local data = file:read("\*a") file:close() return json.decode(data) end local emitter = display.newEmitter(loadParams("confetti.json")) 

confetti.json

{ "textureFileName":"confetti.png", "angle":90, "duration":-1, "sourcePositionVariancex":640, "sourcePositionVariancey":480, "speed":100, "gravityy":98, "rotationStart":0, "rotationStartVariance":0, "rotationEnd":720, "rotationEndVariance":49, "startColorRed":1, "startColorVarianceRed":1, "finishColorRed":1, "startColorGreen":1, "startColorVarianceGreen":1, "finishColorGreen":1, "startColorBlue":1, "startColorVarianceBlue":1, "finishColorBlue":1, "startColorAlpha":1, "finishColorAlpha":1, "blendFuncSource":1, "particleLifespan":10, "blendFuncDestination":1, "startParticleSize":30, "finishParticleSize":30, "maxParticles":300, }

As you can see from above, I’ve set both startColorAlpha and finishColorAlpha to 1, so I don’t know why the confetti is still transparent.

Any help/suggestions appreciated.

Thanks in advance!

KC

Hi KC,

Most likely this is a result of your “blendFunc[]” settings, not alpha. Changing those values are for very specific blending customizations, and it’s not for the light-of-heart… you need to understand OpenGL-ES 2 blending modes and so forth.

See here for options, if you want to experiment. You might just want to omit those from your JSON file entirely.

https://docs.coronalabs.com/api/type/EmitterObject/index.html#particles-blend-modes

Hope this helps,

Brent

Hi Brent,

I won’t pretend to know anything about OpenGL, but I would like to believe I know a thing or two about Corona > :smiley:

Thank you for your suggestion about blendFuncSource, but it did NOT fix my problem.

I literally tried ALL possible values for blendFuncSource (i.e. 0, 1, 774, 775, 770, 771, 772, 773, 776, 768, 769) and (as you suggested) omitting blendFuncSource completely, but that didn’t work either.

As far as I am concerned, I don’t think blendFuncSource is the culprit here…

In any case, this issue is still unsolved, so HELP!!!

KC

Update:

So while changing the values of blendFuncSource did not solve the issue, changing the value of blendFuncDestination did!

For anyone viewing this topic with a similar problem,

blendFuncSource:1

blendFuncDestination:771

achieved the desired behavior for me! (the particles were solid and no longer transparent)

Thank you Brent for your suggestion.

KC

Hi KC,

Most likely this is a result of your “blendFunc[]” settings, not alpha. Changing those values are for very specific blending customizations, and it’s not for the light-of-heart… you need to understand OpenGL-ES 2 blending modes and so forth.

See here for options, if you want to experiment. You might just want to omit those from your JSON file entirely.

https://docs.coronalabs.com/api/type/EmitterObject/index.html#particles-blend-modes

Hope this helps,

Brent

Hi Brent,

I won’t pretend to know anything about OpenGL, but I would like to believe I know a thing or two about Corona > :smiley:

Thank you for your suggestion about blendFuncSource, but it did NOT fix my problem.

I literally tried ALL possible values for blendFuncSource (i.e. 0, 1, 774, 775, 770, 771, 772, 773, 776, 768, 769) and (as you suggested) omitting blendFuncSource completely, but that didn’t work either.

As far as I am concerned, I don’t think blendFuncSource is the culprit here…

In any case, this issue is still unsolved, so HELP!!!

KC

Update:

So while changing the values of blendFuncSource did not solve the issue, changing the value of blendFuncDestination did!

For anyone viewing this topic with a similar problem,

blendFuncSource:1

blendFuncDestination:771

achieved the desired behavior for me! (the particles were solid and no longer transparent)

Thank you Brent for your suggestion.

KC