Yes, I could do it all in a single scene but I don’t think of it as a good way of programming.
In one scene I would have to manage:
being able to extricate yourself with upgrades, debugging and anything else seems like a feat just to think about it!
In the game I would therefore keep only the management of sending and receiving data on the server and I tried to move the first piece to another scene.
How I can I solve the event handling between scenes?
if in the first setup scene I have for example:
netSetup.lua file - start ------------------------------------------- ------------------
photon = require “plugin.photon”
LoadBalancingClient = photon.loadbalancing.LoadBalancingClient
…
local client = LoadBalancingClient.new (appInfo.ServerAddress, appInfo.AppId, appInfo.AppVersion)
function client: onOperationResponse (errorCode, errorMsg, code, content)
...
end
function client: onStateChange (state)
...
end
function client: onError (errorCode, errorMsg)
...
end
function client: onEvent (code, content, actorNr)
...
end
function client: sendData ()
...
end
function client: timer (event)
- this one you have to call every 100 ms when connected to server
self: update ()
end
...
- on start photon you have to set this timer
timerId = timer.performWithDelay (100, client, 0)
netSetup.lua - end file ------------------------------------------- ------------------
how can I ‘migrate’ my client object on next gaming scene? with event and timer?
Timer I think to stop and start again: I found that the connection drop after 2 seconds that the function client: timer(event) doesn’t works.
But about to handle events on another scene ?