Thanks for that- I’ll be sure to save it for future reference. I’m actually not going to have to use that though because I’ve changed the way my program functions.
This is a simple multi-color strobe, but I’m having performance issues. It starts off fast, but overtime slows to ~1 FPS. I guessed that it kept drawing rectangles over each other to the point where there were thousands, and I thought I had fixed that through doing object:removeSelf() but it doesn’t seem to work. If anyone could tell me what I’m doing wrong that would be very helpful- thanks!
[code]
_W = display.contentWidth
_H = display.contentHeight
strobeTime = 5
local function pinkLight()
local pink = display.newRect( 0, 0, _W, _H )
pink:setFillColor(255, 105, 180)
transition.to( pink, { time=strobeTime, onComplete = redLight} )
yellowLight:removeSelf()
end
local function yellowLight()
local yellow = display.newRect( 0, 0, _W, _H )
yellow:setFillColor(255, 255, 0)
transition.to( yellow, { time=strobeTime, onComplete = pinkLight} )
whiteLight:removeSelf()
end
local function whiteLight()
local white = display.newRect( 0, 0, _W, _H )
white:setFillColor(255, 255, 255)
transition.to( white, { time=strobeTime, onComplete = yellowLight} )
blueLight:removeSelf()
end
local function blueLight()
local blue = display.newRect( 0, 0, _W, _H )
blue:setFillColor(0, 0, 255)
transition.to( blue, { time=strobeTime, onComplete = whiteLight} )
greenLight:removeSelf()
end
local function greenLight()
local green = display.newRect( 0, 0, _W, _H )
green:setFillColor(0, 255, 0)
transition.to( green, { time=strobeTime, onComplete = blueLight} )
redLight:removeSelf()
end
function redLight()
local red = display.newRect( 0, 0, _W, _H )
red:setFillColor(255, 0, 0)
transition.to( red, { time=strobeTime, onComplete = greenLight} )
pinkLight:removeSelf()
end
pinkLight()
[/code] [import]uid: 66386 topic_id: 14108 reply_id: 51996[/import]