Hey Jeremy.
You could use object.isVisible = true in an “if statement” but I’d probably opt for writing a function like so:
local function createObject()
myObj = display.newImage ("theObject.png");
myObj.x = 200
myObj.y = 200
myObj.alpha = 1
exampleGroup:insert(myObj)
function touchTheObject(event)
myObj.alpha = .5
end
myObj:addEventListener( "touch", touchTheObject )
end
You can then “call” the function anytime you like by simply writing the function name, like this:
createObject()
This is quite powerful because within the function you have a touch event for that specific object. Touching it changes it’s alpha to make it 50% transparent. Outside that function, you could write another function, and call it using a timer every 5 seconds. It would check to see what the alpha of myObj is, and if it is less than 1, set it back to 1 again. The code for such a function would look something like this:
local function alphaTimer()
if myObj.alpha \< 1 then
myObj.alpha = 1
end
end
myTimer = timer.performWithDelay(5000,alphaTimer, 0)
You could set up a timer which checks the alpha of a number of objects, simply by adding extra if statements to the alphaTimer function, (if myObj2.alpha < 1…etc).
Finally, it’s a reasonably short jump from that, to checking if the alpha of 5 objects is less than 1, and if it is, calling “createObject” as suggested above.
The reason I didn’t write out a full block of code for you is that by doing so, you wouldn’t learn anything. It’s much better to work the solution out than just being given the answer. If you get stuck let me know and I’ll help where I can. The solution I suggest is not the most elegant or best method, but it should work.
Good luck, and welcome to the community:)
Dan [import]uid: 67933 topic_id: 25687 reply_id: 103863[/import]