Hi everybody!
I am new to programming. I have downloaded Corona last week to learn to code and have fun with my son playing games.
We went through the “Getting Started” tutorial and now we are trying to experiment.
My setup: Version 2018.3326 (2018.6.25) on MacOS High Sierra.
Issue Summary.
I have n cats displayed on screen. If I tap on three cats, say cat_j, cat_k, cat_l, then only these cats should rotate 180.
Please observe: the touches must be sequential and the order
is irrelevant (i.e., j -> k -> l, or j->l-> k … and so on on through all the 6 permutations).
Issue Details.
I skip the code I used to display the cats: basically I have as many local variables
cat_i as png images I have, i =1,…, n, and I have named them, i.e.
cat_i.name=“cat_i” for i=1,…,n.
I first tried with cat_1.
local function turn(event)
event.target:rotate(180)
end
cat1:addEventListener(“touch”,turn)
It worked.
But then, when I tried with cat1 and cat2, I realize it is above my very low skills.
- - First try.
local function turnA(event)
if event.target.name==“cat1” then
if event.target.name==“cat2" then
cat1:rotate(180)
cat2:rotate(180)
end
end
end
cat1:addEventListener(“touch”,turnA)
cat2:addEventListener(“touch”,turnA)
-
- Nothing happens and I get no error. :unsure:
-
- Second try, (now with cat3 and cat4).
local function turnB(event)
if (event.target.name==“cat3") and (event.target.name==“cat4") then
cat3:rotate(180)
cat4:rotate(180)
end
end
cat3:addEventListener(“touch”,turnB)
cat4:addEventListener(“touch”,turnB)
As above, nothing happens and I get no error. :wacko:
Could you help me, please?