Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- home.lua
- local backToButton = containerClass.new(sceneGroup)
- print(backToButton.swapColorsOnTap) -- This returns false
- backToButton.swapColorsOnTap = true
- print(backToButton.swapColorsOnTap) -- This returns true
- -- container.lua
- require "lib.utils"
- local boxClass = require("classes.box")
- local _M = {}
- -- Default values for the feature class
- local self = {
- -- Public Variables
- contains = {}, -- a table of boxes
- popUps = {}, -- a table of containers
- popUpsVisible = false,
- swapColorsOnTap = false,
- -- Private Variables
- parent = nil,
- group = nil,
- class = "Container",
- isType = "Unknown",
- }
- function self:tap(event)
- print("container was tapped")
- print(self.swapColorsOnTap) -- This always returns false
- if self.swapColorsOnTap then
- print ("swapColorsonTap is true!")
- for i = 1, #self.contains do
- print("got a box")
- if self.contains[i].class == "Box" then self.contains[i]:swapColors() end
- end
- end
- return true
- end
- function self:init(parentGroup)
- print("Initializing the container")
- -- Create a group for the container and insert it into the parent group
- self.group = display.newGroup()
- parentGroup:insert(self.group)
- self.group:addEventListener("tap")
- end
- -- Create a new instance of the feature class, use the options if provided.
- function _M.new(group)
- local newContainer = table.deepcopy(self)
- newContainer:init(group)
- return newContainer
- end
- return _M
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement