In other words, I want the following: I touch an object and this 1 is removed and new 2 of the same object are shown; then when I touch those 2 they are removed and new 3 of the same object are shown and so on.
Have you written any code yet, or are you just thinking out the method? It’s not necessarily complicated at first glance, but if you have any code, please post what you have so far.
local b = display.newImageRect(“bird.png”, 64, 64);
b.x, b.y = math.random(64,416), math.random(64, 256);
return b;
end
bird = newBird();
function create(e)
if(e.phase == “ended” )then
bird:removeSelf();
for num = 1,2 do
birds[num] = newBird();
birds[num].x = math.random(64, 416);
birds[num].y = math.random(64, 256);
end
end
end
bird:addEventListener(“touch”, create)
[/code]
That is what I tried…
(“num = 1,2” was a = 1, b = 2, because I was trying to make an incrementation of “b”, but I couldn’t make it work…) [import]uid: 162818 topic_id: 31264 reply_id: 125069[/import]
This is just a quick example…it doesn’t react quite like you asked for but I think it will help. Here you touch a bird and it just splits into two more…not you touch 2 birds and you get 3 like you seem to be asking.
[code]
function newBird()
local b = display.newImageRect(“bird.png”, 64, 64);
b.x, b.y = math.random(64,416), math.random(64, 256);
return b;
end
bird = newBird();
birds = {bird}
function create(e)
if(e.phase == “ended” )then
e.target:removeSelf();
birds[#birds+1] = newBird();
birds[#birds]:addEventListener(“touch”, create)
birds[#birds+1] = newBird();
birds[#birds]:addEventListener(“touch”, create)
end
end
Have you written any code yet, or are you just thinking out the method? It’s not necessarily complicated at first glance, but if you have any code, please post what you have so far.
local b = display.newImageRect(“bird.png”, 64, 64);
b.x, b.y = math.random(64,416), math.random(64, 256);
return b;
end
bird = newBird();
function create(e)
if(e.phase == “ended” )then
bird:removeSelf();
for num = 1,2 do
birds[num] = newBird();
birds[num].x = math.random(64, 416);
birds[num].y = math.random(64, 256);
end
end
end
bird:addEventListener(“touch”, create)
[/code]
That is what I tried…
(“num = 1,2” was a = 1, b = 2, because I was trying to make an incrementation of “b”, but I couldn’t make it work…) [import]uid: 162818 topic_id: 31264 reply_id: 125069[/import]
This is just a quick example…it doesn’t react quite like you asked for but I think it will help. Here you touch a bird and it just splits into two more…not you touch 2 birds and you get 3 like you seem to be asking.
[code]
function newBird()
local b = display.newImageRect(“bird.png”, 64, 64);
b.x, b.y = math.random(64,416), math.random(64, 256);
return b;
end
bird = newBird();
birds = {bird}
function create(e)
if(e.phase == “ended” )then
e.target:removeSelf();
birds[#birds+1] = newBird();
birds[#birds]:addEventListener(“touch”, create)
birds[#birds+1] = newBird();
birds[#birds]:addEventListener(“touch”, create)
end
end