Hi there,
I might be trying to do something thats not really possible but in my head it seems ok but doesn’t work, hopefully I can explain.
I’ve created a few scenes in Sprite Deck which if your familiar outputs two files for each scene level1.lua / _level1.lua and you can reference to objects you create inside _level1.lua with this.object.
I also use the Director class option within Sprite Deck also so I can switch between scenes.
All this works nicely, I have a main menu and a main game scene and you can enter the main game and I have a menu button which takes you back to the main menu and that all works.
Originally I created my controls (some basic x and y movement controls) inside level1.lua which references to this.object.x / this.object.y (that exist in _level1.lua)
But I thought it would be nice to separate the controls code and put it in a new module file called controls.lua and reference back in level1.lua:
[lua]controls = require(“controls”)
controls.mycontrols()[/lua]
problem is because the controls.lua file requires objects that are in _level1.lua I have to include local references to _level1.lua inside controls.lua which all works but then the button doesn’t work and the transition breaks.
So I’m assuming Director breaks.
Hopefully you have followed most of that and it kind of makes sense. The point of all this is to understand how to separate chunks of code into modules and make them all happily work together with Director class.
Is this possible or is the way director class is made I can’t do this? Or am I doing something wrong… which hopefully is the case.
Hope someone can help.
[import]uid: 33866 topic_id: 6766 reply_id: 306766[/import]