Hi
Is it possible to run function(event) manually ?
Function react on push button can I run the same function when I want to ?
[import]uid: 13156 topic_id: 8181 reply_id: 308181[/import]
Functions run whenever you call them. Just type function() to call the function. [import]uid: 12108 topic_id: 8181 reply_id: 29162[/import]
I know , but what about functions react on events ? function(event)
Terminal is saying event = nil
[import]uid: 13156 topic_id: 8181 reply_id: 29165[/import]
You will have to give more background on what exactly you are trying to do, because I don’t see the point of manually calling a function that needs an event. Like, if the function reacts to the location of a tap, then there’s no point calling that function without a location for it to respond to. [import]uid: 12108 topic_id: 8181 reply_id: 29169[/import]
Ok you are right…
I have a restart button it run’s function(event) and do something.
When for example my ship goes out the screen I need to do exactly the same what restart button is doing.
So I thought that I can call this function (from restart button) when for example object.x >480 then…
[import]uid: 13156 topic_id: 8181 reply_id: 29171[/import]
Well something in your function must be using the event object, because otherwise it wouldn’t matter if event = nil. Post your code. [import]uid: 12108 topic_id: 8181 reply_id: 29174[/import]
Exactly is using touch event and I was wondering if I can run the same function without this event.
local restartGame = function(event)
if event.phase == “began” then …
I thought that I can run this like this:
restartGame()
but now I see it’s rather stupid idea so I have to write the same code in different function but without event. [import]uid: 13156 topic_id: 8181 reply_id: 29176[/import]
Just check if the event object is nil before trying to use it:
if event == nil or event.phase == "began" then...
[import]uid: 12108 topic_id: 8181 reply_id: 29187[/import]
Thank you jhocking you help me again… it’s work’s exactly what I want.
Still learning…
[import]uid: 13156 topic_id: 8181 reply_id: 29188[/import]