M
M
mrdragon90002018-06-21 06:56:16
Corona SDK
mrdragon9000, 2018-06-21 06:56:16

How to work with compositor in corona SDK? How to pause timers, delete variables in hide and destroy events if they are not visible there?

In the stock composer-e, the official documentation says that all scene objects must be created in the scene:create event, and deleted / suspended in the scene:hide and scene:destroy events. I can't figure out how this should work, because variables created in the scene:create function cannot be seen in other functions (if not made global)?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Lerg, 2018-06-21
@mrdragon9000

Variables that should be visible in different scene methods can either be created at the beginning of the file as local variables, or placed in self.

local some_var = 'test local'
local scene = composer.newScene()
function scene:create()
  self.other_var = 'test self'
end
function scene:show()
  print(some_var, self.other_var)
end

Not all variables need to be deleted.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question