broken wip

This commit is contained in:
Fox 2016-03-31 18:59:16 -07:00
parent 59842a2a3d
commit 3c1724d9fb
5 changed files with 38 additions and 2 deletions

View File

@ -16,6 +16,11 @@ do
graphics.print("e", self.x, self.y)
return self
end,
addChild = function(self, child)
self.child[#self.child + 1] = child
child.parent = self
return self
end,
move = function(self, x, y)
if x then
self.x = self.x + x

View File

@ -63,6 +63,9 @@ pop.create = function(element, parent, ...)
if parent == nil then
parent = pop.screen
end
if parent then
print(parent.__class, parent.__class.__name, parent.__class.__base, parent.__class.__parent)
end
element = pop.elements[element](parent, ...)
if parent then
insert(parent.child, element)

View File

@ -16,6 +16,11 @@ do
graphics.print("e", self.x, self.y)
return self
end,
addChild = function(self, child)
self.child[#self.child + 1] = child
child.parent = self
return self
end,
move = function(self, x, y)
if x then
self.x = self.x + x

View File

@ -63,6 +63,9 @@ pop.create = function(element, parent, ...)
if parent == nil then
parent = pop.screen
end
if parent then
print(parent.__class, parent.__class.__name, parent.__class.__base, parent.__class.__parent)
end
element = pop.elements[element](parent, ...)
if parent then
insert(parent.child, element)

View File

@ -51,10 +51,30 @@ pop.load = ->
pop.screen = pop.create("element", false)\setSize(graphics.getWidth!, graphics.getHeight!)
print "created \"pop.screen\""
instanceOfElement = (object) ->
if object.__class
class = object.__class
if class.__name == "element"
return true
while class.__parent
class = class.__parent
if class.__name == "element"
return true
return false
-- creates an element with specified parent (parent can be false)
pop.create = (element, parent=pop.screen, ...) ->
-- 1: if parent is object, use it, 2: if parent is false, use it (use false), 3: if parent is nil, use pop.screen as parent
element = pop.elements[element](parent, ...)
--if parent
-- print parent.__class, parent.__class.__name, parent.__class.__base, parent.__class.__parent
--element = pop.elements[element](parent, ...)
if instanceOfElement parent
element = pop.elements[element](parent, ...)
else
element = pop.elements[element](pop.screen, parent, ...)
if parent
insert parent.child, element