HI
I need to make a function with objcet Timer but i don’t know how to change the properties of a image(visible and invisible)
Thank you
[import]uid: 100428 topic_id: 21574 reply_id: 321574[/import]
HI
I need to make a function with objcet Timer but i don’t know how to change the properties of a image(visible and invisible)
Thank you
[import]uid: 100428 topic_id: 21574 reply_id: 321574[/import]
Hello erasmo.marciano,
here is some simple code to get you started…
local ourBox = display.newCircle( 150, 150, 15 )
-- set starting properties of our object
ourBox.isVisable = false;
ourBox.alpha = 0;
local switchSeeMe = false;
-- print timer is running
local function printTimer()
print("Timer Running!");
-- we can also have our objects visable or invisable here
if switchSeeMe == false then
ourBox.isVisable = true;
ourBox.alpha = 1;
switchSeeMe = true;
elseif switchSeeMe == true then
ourBox.isVisable = false
ourBox.alpha = 0;
switchSeeMe = false;
end
end
-- cancel timer
local function cancelTimer(e)
if e.phase == "ended" then -- up click from finger/mouse
-- stop our timer
timer.cancel(ourTimer);
print("Timer Cancelled!");
end
end
-- run our printtimer function every 2 seconds and loop forever
ourTimer = timer.performWithDelay(2000, printTimer, -1); -- ie: -1 = loop forever 10 = run 10 times
-- listen for a touch event on our screen
-- ourBox:addEventListener("touch", cancelTimer); -- use our object as a button to stop
Runtime:addEventListener("touch", cancelTimer);
Hope that will get ya going…study the code and you can
adapt it to what your looking for…
Happing Coding, have fun! 
Larry
[import]uid: 107633 topic_id: 21574 reply_id: 85540[/import]
Thank you
But my code don’t work
local function showCalciatore(show)
local rand = math.random(3)
local IDmg=rand…".png"
local calciatore = display.newImage(IDmg)
if (show==“false”)then
print(" show :" … show)
calciatore.isVisible = false
end
if (show==“true”)then
print(" show :" … show)
calciatore.isVisible = true
end
calciatore.x = 50
calciatore.y = 220
end
I’m sure that " variable show" change the valure (true|false)
But don’t work
I always see image.
[import]uid: 100428 topic_id: 21574 reply_id: 85553[/import]
Another simple option is to move it out of screen by setting a x value… e.g image.x = -100
[import]uid: 84539 topic_id: 21574 reply_id: 85556[/import]
I tried
local function showCalciatore(show)
local rand = math.random(3)
local IDmg=rand…".png"
local calciatore = display.newImage(IDmg)
if (show==“false”)then
print(" show :" … show)
calciatore.isVisable = false;
calciatore.x = -150
calciatore.y = -220
elseif (show==“true”)then
print(" show :" … show)
calciatore.isVisable = true;
calciatore.x = 50
calciatore.y = 220
end
end
BUT DON’T WORK [import]uid: 100428 topic_id: 21574 reply_id: 85558[/import]
Hi erasmo.marciano,
Post some code as to exactly what you want to do, and
I’ll take a look at it…PLEASE use the code tags
listed below…
Makes is a lot easier to read your code…

Thanks
Happy Coding 
Larry [import]uid: 107633 topic_id: 21574 reply_id: 85561[/import]
local function showCalciatore(show)
local rand = math.random(3)
local IDmg=rand..".png"
local calciatore = display.newImage(IDmg)
if (show=="false")then
print(" show :" .. show)
calciatore.isVisable = true;
calciatore.x = -150
calciatore.y = -220
elseif (show=="true")then
print(" show :" .. show)
calciatore.isVisable = false;
calciatore.x = 50
calciatore.y = 220
end
end
-----
local function onGlobalCollision( event )
if ( event.phase == "began" ) then
-- print( "Global report: " .. event.object1.nome .. " & " .. event.object2.nome .. " collision began" )
if( event.object1.nome == "PUFFO" and event.object2.nome =="bottonnew" )then
redTotal = redTotal + 1
updateRimbalzi()
end
if( event.object1.nome == "PUFFO" and event.object2.nome =="birba" )then
redTotal = redTotal - 1
updateRimbalzi()
media.playEventSound( "beep\_mp3.mp3" )
----------LOOK HERE
showCalciatore("true")
end
if( event.object1.nome == "PUFFO" and event.object2.nome =="gargamella" )then
redTotal = redTotal - 2
updateRimbalzi()
media.playEventSound( "fischio.mp3" )
end
if( event.object1.nome == "PUFFO" and event.object2.nome =="PortaTop" )then
redTotal = redTotal + 5
updateRimbalzi()
media.playEventSound( "Stadiook.mp3" )
----------LOOK HERE
showCalciatore("false")
end
elseif ( event.phase == "ended" ) then
end
end
Runtime:addEventListener( "collision", onGlobalCollision )
THANKS
[import]uid: 100428 topic_id: 21574 reply_id: 85562[/import]
If you are using boolean variables - please remove the " around true or false.
if show == false then
if show then
Regards, Joakim [import]uid: 81188 topic_id: 21574 reply_id: 85564[/import]
Hello,
Joakim is correct, if using “true” vs true you will get
different results…
Try that and see if that works for ya… 
also, you might want to move the isVisable flag after you
move to x and y and set the alpha flag to false…
Let us know how is works for ya…or don’t work for ya…
Thanks for putting it in the code tags… looks alot better. 
Good luck…
Larry
[import]uid: 107633 topic_id: 21574 reply_id: 85565[/import]
Although you would normally use true instead of true, his code actually checks for “true” anyway, so that shouldn’t be affecting it.
In this part:
if (show=="false")then
print(" show :" .. show)
calciatore.isVisable = true;
calciatore.x = -150
calciatore.y = -220
elseif (show=="true")then
print(" show :" .. show)
calciatore.isVisable = false;
calciatore.x = 50
calciatore.y = 220
end
you are setting isVisible to true when the x and y are off screen, and to false when it is on screen.
Should it not be the other way round:
if (show=="false")then
print(" show :" .. show)
calciatore.isVisible = false;
calciatore.x = -150
calciatore.y = -220
elseif (show=="true")then
print(" show :" .. show)
calciatore.isVisible = true;
calciatore.x = 50
calciatore.y = 220
end
Also it could be a localisation thing but you had it spelt as ‘isVisable’ instead of ‘isVisible’. [import]uid: 84115 topic_id: 21574 reply_id: 85571[/import]
Or why not,
[code]
if (calciatore.isVisible==false)then
print(" show :" … show)
calciatore.isVisible = true;
calciatore.x = 150
calciatore.y = 220
else
print(" show :" … show)
calciatore.isVisible = false;
calciatore.x = -150
calciatore.y = -220
end
[/code] [import]uid: 81188 topic_id: 21574 reply_id: 85573[/import]
local function showCalciatore(show)
local rand = math.random(3)
local IDmg=rand..".png"
local calciatore = display.newImage("1.png")
calciatore.x = 50
calciatore.y = 220
if (show=="false")then
print(" show :" .. show)
calciatore.isVisible = false;
elseif (show=="true")then
print(" show :" .. show)
calciatore.isVisible = true;
end
end
I tried as you suggested but don’t work again.
Is there a method destroy? or clear?
Are you sure that objcet.isVisible = false|true works? ;
thank [import]uid: 100428 topic_id: 21574 reply_id: 85589[/import]
[code]
local calciatore = display.newImage(“1.png”)
calciatore.x = 50
calciatore.y = 220
calciatore.isVisible = false
local function showCalciatore(value)
if (value==false)then
calciatore.isVisible = false;
else
calciatore.isVisible = true;
end
end
showCalciatore(true)
[/code] [import]uid: 81188 topic_id: 21574 reply_id: 85594[/import]
TNKS
But also this method doesn’t work
I’m going crazy 
[import]uid: 100428 topic_id: 21574 reply_id: 85605[/import]
You are kidding me, I just tested this and its nothing special - just straight forward code that works as it should.
Copy and paste this into a new project and put in the image and run it, i beat 100 bucks that it will work. There must be some other problems you are having. What are the console saying? Give me all the code you are having and I will sort it out for you.
Joakim [import]uid: 81188 topic_id: 21574 reply_id: 85608[/import]
Your syntax for isVisible is bad, you are using isVisable…theres nothing like that…
Joakim [import]uid: 81188 topic_id: 21574 reply_id: 85609[/import]
I have coy and paste you code
http://www.giralatina.it/catalogo/gallery.tar my projcet
tnks
[import]uid: 100428 topic_id: 21574 reply_id: 85611[/import]
Hi
When I use isVisable don’t work
I have Error attempt to concatenate local value [import]uid: 100428 topic_id: 21574 reply_id: 85615[/import]
I’m sorry
There is Error because i Have write this
print(" show :" … value)
Sorry again [import]uid: 100428 topic_id: 21574 reply_id: 85617[/import]
GREAT NOW IT’S WORK
But there is a problem …
I would that the value objcet calciatore is dynamic
local calciatore = display.newImage("1.png")
local rand = math.random(3)
local IDmg=rand..".png"
local calciatore = display.newImage(IDmg)
How I can do this?
Thank you
n.b
Now it’s work with isVisible
Thank a lot
[import]uid: 100428 topic_id: 21574 reply_id: 85619[/import]