Particle Emitter on Build 759+ causes screen flickering

I’m using the custom particle emitter located here:

http://developer.anscamobile.com/code/custom-particle-emitter-package

and have run into a new issue when using build 759 and higher. The screen seems to flicker quite often and I’m not sure why. The stable build does not do this. In testing the screen only seems to flicker when there are physics objects on screen. I may be wrong about this.

What I do in my game is put a particle emitter over a bomb to look like a lit fuse. I noticed that build 759 contains a lot of graphical changes so I think this may be the cause. I have thrown together a quick sample. Please see for yourself. For simplicity sake here are the 2 files you need:

--emitter.lua  
  
module(..., package.seeall)  
  
math.randomseed(os.time())  
  
function createEmitter(radiusRange,thickness, particleDuration, initAlpha, endAlpha)  
  
 local customEmitter = {}  
  
 customEmitter.radiusRange = radiusRange  
  
 customEmitter.thickness = thickness  
 customEmitter.particleDuration = particleDuration  
  
 customEmitter.initAlpha = initAlpha  
 customEmitter.endAlpha = endAlpha  
  
 customEmitter.colorR = nil  
 customEmitter.colorG = nil  
 customEmitter.colorB = nil  
  
 return customEmitter  
  
end  
  
function setColor(customEmitter, red, green, blue)  
  
 if(red~=nil) then  
 customEmitter.colorR = red  
 end  
  
 if(green~=nil) then  
 customEmitter.colorG = green  
 end  
  
 if(blue~=nil) then  
 customEmitter.colorB = blue  
 end  
end  
  
function emit(customEmitter, group, ex, ey)  
  
 local rx = math.random(ex - (customEmitter.radiusRange/15), ex + (customEmitter.radiusRange/15))  
 local ry = math.random(ey - (customEmitter.radiusRange/15), ey + (customEmitter.radiusRange/15))  
  
 local dx = math.random( ex - customEmitter.radiusRange, ex + customEmitter.radiusRange)  
 local ranSign = math.random(2)  
  
 if( ranSign == 2) then ranSign = -1 end   
  
 local dy = (ranSign\*math.sqrt((customEmitter.radiusRange\*customEmitter.radiusRange) - ((dx - ex)\*(dx - ex)))) + ey  
  
  
 local particle = display.newRect( group, rx - customEmitter.thickness/2, ry - customEmitter.thickness/2, customEmitter.thickness, customEmitter.thickness)  
 particle.alpha = customEmitter.initAlpha  
  
 if( customEmitter.colorR ~= nil) then  
 if(customEmitter.colorR == -1) then  
 particle:setFillColor( math.random(0,255), math.random(0,255), math.random(0,255))  
 else  
 particle:setFillColor( customEmitter.colorR, customEmitter.colorG, customEmitter.colorB)  
 end   
 end  
  
  
 local transC = transition.to(particle, {time = customEmitter.particleDuration, x = dx, y = dy, alpha = customEmitter.endAlpha, transition = easing.outQuad, onComplete = function(event)  
 particle:removeSelf()  
  
 customEmitter = nil  
 group = nil  
 ex = nil  
 ey = nil  
 rx = nil  
 ry = nil  
 dx = nil  
 dy = nil  
 ranSign = nil  
 transC = nil  
  
 end})  
end  
--main.lua  
  
local emitter = require("emitter")  
local physics = require("physics")  
--physics.setDrawMode( "hybrid" )   
local mainGroup = display.newGroup()  
local emit1  
local i  
local mem = display.newText("Memory :"..tostring(collectgarbage("count")), 0, 0, nil, 20)  
physics.start()  
  
local background = display.newRect(0, 0, display.contentWidth, display.contentHeight)  
local ball = display.newCircle(250, 350, 50)  
local ground = display.newRect(0, 400, 500, 10)  
local top = display.newCircle(ball.x, ball.y-35, 10)  
mainGroup:insert(background)  
mainGroup:insert(ball)  
mainGroup:insert(top)  
mainGroup:insert(ground)  
background:setFillColor(0, 0, 255)  
ground:rotate(-2)  
physics.addBody(ball, { friction=2, radius=50 } )  
physics.addBody(top, { radius=10 } )  
physics.addBody(ground, "static", { friction=2, density=3 } )  
local myJoint = physics.newJoint( "weld", ball, top, 250,300 )  
  
local function init()  
  
emit1 = emitter.createEmitter(40, 5, 500, 0.5, 0)  
emitter.setColor(emit1,255,140,0)  
  
end  
local function burst(event)  
  
 for i = 1,10 do  
 --emitter.emit(emit1, mainGroup, event.x, event.y)   
 emitter.emit(emit1, mainGroup, top.x - (ball.x-top.x), top.y - (ball.y-top.y))   
 end   
  
 mem.text = "Memory :"..tostring(collectgarbage("count"))  
  
end  
  
Runtime:addEventListener("enterFrame", burst)  
  
init()  

This is going to cause issues for me because I am trying to implement Game center and I also want my game to work properly on the iPad 3. If this is a bug then there is no build that will allow this. Thanks for taking a look! [import]uid: 31262 topic_id: 23790 reply_id: 323790[/import]

I’ve been noticing some strange graphical “glitching” myself. I uploaded some code and hoping for the some fast resolution. I have faith that the ansca team will lock it down!:slight_smile: [import]uid: 21331 topic_id: 23790 reply_id: 95749[/import]

Anyone else experiencing similar issues with the new builds? Anyone at Ansca able to test and see if you get similar results? [import]uid: 31262 topic_id: 23790 reply_id: 96167[/import]

Just want to add that I’m definitely getting the “flicker” effect same as you, with other things too. Mentioned to Carlos, uploaded code, crossing fingers!! [import]uid: 21331 topic_id: 23790 reply_id: 96187[/import]

Tony are you getting this flickering when using particles only? Glad I’m not alone here. Also glad you got the ball rolling already. [import]uid: 31262 topic_id: 23790 reply_id: 96368[/import]

Mostly particles, but also during an AOE attack I have where it is scaling outwards in 5 or 6 transitions with physics body stamping (removal/addition) for each increment. Also seeing occasional moments where an image is just missing…

I started with the easy to detect stuff when I sent the code, and was hoping for a little direct communication to help with some of the rest… but the line went dead… lol :slight_smile: Giv’in it some time… [import]uid: 21331 topic_id: 23790 reply_id: 96373[/import]

If too much time passes we should consider posting in the bug forum. That seems to be the only one that gets full attention. [import]uid: 31262 topic_id: 23790 reply_id: 96411[/import]

Did you post a bug report? I don’t know if mine went through since it bombed on the code upload part and I have been unable to re-establish simple communication otherwise…< sigh >
[import]uid: 21331 topic_id: 23790 reply_id: 96943[/import]

I just created a thread in the bug forum that just links back to this thread:

http://developer.anscamobile.com/forum/2012/03/29/build-759-particle-emitter-causes-screen-flickerflash [import]uid: 31262 topic_id: 23790 reply_id: 97154[/import]

Thank you. I’m hoping this will lead to a solution for my initial issue, hopefully, that makes two bullet types that use this mechanism cause the Mac simulator to stutter almost like its locking up… [import]uid: 21331 topic_id: 23790 reply_id: 97171[/import]

Thanks for the working code sample. We were able to reproduce the problem on the Mac simulator and we will look into the issue as soon as we can. Build 758 works and build 776 fails.
[import]uid: 7559 topic_id: 23790 reply_id: 99632[/import]

Thanks Tom you guys rock! Just so you know, I have tested up until build 777 and still get the problem. I also get the issue on devices too (iPhone 4 and iPad 1). [import]uid: 31262 topic_id: 23790 reply_id: 99772[/import]

I get this issue to with the flame especially, whole screen flashes red when emitter starts. [import]uid: 118379 topic_id: 23790 reply_id: 103178[/import]

This looks like the same issue in 13428. The flickering was due to NaN values in emitter.lua. See my follow up here:

http://developer.anscamobile.com/forum/2012/03/10/slow-image-particle-generation-mac-simulator-fine-device#comment-108417 [import]uid: 26 topic_id: 23790 reply_id: 108421[/import]