I wrote this app to test the different transitions and I want to track when all the events have been clicked. Does anyone have an example of how to track events that have been fired off then once a condition has been satisfied fire off another event? Here is what I have so far (I know there is probably a more terse way to do this but I am just learning so take it easy): Also how do you display characters in other languages? Namely Spanish and the like. Also can some show me how to find the center of a display group?
– Experimentin’ with transitions, display groups and other shiz
– main.lua
local w,h = display.contentWidth, display.contentHeight
local d1
local d2
local d3
local d4
local d5
local dStart
local text1
local text2
local text3
local text4
local text5
local startText
local startSquare
local function Main()
dStart = display.newGroup()
dStart.name = “Start Group”
dStart.height = 100
dStart.width = 100
dStart:addEventListener(‘tap’, clearStart)
startText = display.newText( “Start”, (w/2), (h/2), native.systemFont, 18 )
startSquare = display.newRect((w/2),(h/2),100,100)
startSquare:setFillColor(133,33,133)
startSquare.name = “Start Square”
dStart:insert(startSquare)
dStart:insert(startText)
dStart:setReferencePoint( display.CenterReferencePoint )
end
function Start()
d1 = display.newGroup()
d1.name = “display group 1”
d1.height = 100
d1.width = 100
text1 = display.newText( “Hello”, 30, 30, native.systemFont, 18 )
local square1 = display.newRect(0,0,100,100)
square1:setFillColor(133,33,133)
square1.name = “square1”
d1:insert(square1)
d1:insert(text1)
d1:setReferencePoint( display.CenterReferencePoint )
d2 = display.newGroup()
d2.name = “display group 2”
d2.height = 100
d2.width = 100
text2 = display.newText( “bonjour”, 20, 30, native.systemFont, 18 )
local square2 = display.newRect(0,0,100,100)
square2:setFillColor(133,33,133)
square2.name = “square2”
d2:insert(square2)
d2:insert(text2)
d2:setReferencePoint( display.CenterReferencePoint )
d3 = display.newGroup()
d3.name = “display group 3”
d3.height = 100
d3.width = 100
text3 = display.newText( “dia duit”, 20, 30, native.systemFont, 18 )
local square3 = display.newRect(0,0,100,100)
square3:setFillColor(133,33,133)
square3.name = “square3”
d3:insert(square3)
d3:insert(text3)
d3:setReferencePoint( display.CenterReferencePoint )
d4 = display.newGroup()
d4.name = “display group 4”
d4.height = 100
d4.width = 100
text4 = display.newText( “¡hola”, 20, 30, native.systemFont, 18 )
local square4 = display.newRect(0,0,100,100)
square4:setFillColor(133,33,133)
square4.name = “square4”
d4:insert(square4)
d4:insert(text4)
d4:setReferencePoint( display.CenterReferencePoint )
d5 = display.newGroup()
d5.name = “display group 5”
d5.height = 100
d5.width = 100
text5 = display.newText( “ciao”, 35, 30, native.systemFont, 18 )
local square5 = display.newRect(0,0,100,100)
square5:setFillColor(133,33,133)
square5.name = “square4”
d5:insert(square5)
d5:insert(text5)
d5:setReferencePoint( display.CenterReferencePoint )
local listener1 = function(obj)
d1:addEventListener(‘tap’, clearD1)
print("Transition 1 completed on object: " … tostring(obj.name))
end
local listener2 = function(obj)
d2:addEventListener(‘tap’, clearD2)
print("Transition 2 completed on object: " … tostring(obj.name))
end
local listener3 = function(obj)
d3:addEventListener(‘tap’, clearD3)
print("Transition 3 completed on object: " … tostring(obj.name))
end
local listener4 = function(obj)
d4:addEventListener(‘tap’, clearD4)
print("Transition 4 completed on object: " … tostring(obj.name))
end
local listener5 = function(obj)
d5:addEventListener(‘tap’, clearD5)
print("Transition 5 completed on object: " … tostring(obj.name))
end
– Diagonal top left to center
transition.to(d1, {time=1500, alpha=1, x=(w/2), y=(h/2), transition=easing.outExpo, onComplete=listener1 })
– Sideways top left to top right
transition.to(d2, {time=1500, alpha=1, x=(w-50), y, transition=easing.inExpo, onComplete=listener2})
– Sideways top left to bottom left
transition.to(d3, {time=1500, alpha=1, x, y=(h-50), transition=easing.outExpo, onComplete=listener3})
– Stays in place
transition.to(d4, {time=1500, alpha=1, x, y, onComplete=listener4})
– Diagonal top left to bottom right
transition.to(d5, {time=1500, alpha=1, x=(w-50), y=(h-50), transition=easing.inExpo, onComplete=listener5 })
end
function clearStart()
startText.text = “Go!”
transition.to(dStart, {time=1500, alpha=0, x, y, onComplete=Start })
print(“Hi”)
end
function clearD1()
text1.text = “good bye!”
transition.to(d1, {time=1500, alpha=0, x, y, onComplete=listener1 })
end
function clearD2()
text2.text = “au revoir!”
transition.to(d2, {time=1500, alpha=0, x, y, onComplete=listener2 })
end
function clearD3()
text3.text = “beannacht!”
transition.to(d3, {time=1500, alpha=0, x, y, onComplete=listener3 })
end
function clearD4()
text4.text = “addio!”
transition.to(d4, {time=1500, alpha=0, x, y, onComplete=listener4 })
end
function clearD5()
text5.text = “adios!”
transition.to(d5, {time=1500, alpha=0, x, y, onComplete=listener5 })
end
Main() [import]uid: 125860 topic_id: 33615 reply_id: 333615[/import]