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]