mirror of
https://github.com/TangentFoxy/Pop.Box.git
synced 2024-12-15 12:44:20 +00:00
broken wip
This commit is contained in:
parent
59842a2a3d
commit
3c1724d9fb
@ -16,6 +16,11 @@ do
|
|||||||
graphics.print("e", self.x, self.y)
|
graphics.print("e", self.x, self.y)
|
||||||
return self
|
return self
|
||||||
end,
|
end,
|
||||||
|
addChild = function(self, child)
|
||||||
|
self.child[#self.child + 1] = child
|
||||||
|
child.parent = self
|
||||||
|
return self
|
||||||
|
end,
|
||||||
move = function(self, x, y)
|
move = function(self, x, y)
|
||||||
if x then
|
if x then
|
||||||
self.x = self.x + x
|
self.x = self.x + x
|
||||||
|
@ -63,6 +63,9 @@ pop.create = function(element, parent, ...)
|
|||||||
if parent == nil then
|
if parent == nil then
|
||||||
parent = pop.screen
|
parent = pop.screen
|
||||||
end
|
end
|
||||||
|
if parent then
|
||||||
|
print(parent.__class, parent.__class.__name, parent.__class.__base, parent.__class.__parent)
|
||||||
|
end
|
||||||
element = pop.elements[element](parent, ...)
|
element = pop.elements[element](parent, ...)
|
||||||
if parent then
|
if parent then
|
||||||
insert(parent.child, element)
|
insert(parent.child, element)
|
||||||
|
@ -16,6 +16,11 @@ do
|
|||||||
graphics.print("e", self.x, self.y)
|
graphics.print("e", self.x, self.y)
|
||||||
return self
|
return self
|
||||||
end,
|
end,
|
||||||
|
addChild = function(self, child)
|
||||||
|
self.child[#self.child + 1] = child
|
||||||
|
child.parent = self
|
||||||
|
return self
|
||||||
|
end,
|
||||||
move = function(self, x, y)
|
move = function(self, x, y)
|
||||||
if x then
|
if x then
|
||||||
self.x = self.x + x
|
self.x = self.x + x
|
||||||
|
@ -63,6 +63,9 @@ pop.create = function(element, parent, ...)
|
|||||||
if parent == nil then
|
if parent == nil then
|
||||||
parent = pop.screen
|
parent = pop.screen
|
||||||
end
|
end
|
||||||
|
if parent then
|
||||||
|
print(parent.__class, parent.__class.__name, parent.__class.__base, parent.__class.__parent)
|
||||||
|
end
|
||||||
element = pop.elements[element](parent, ...)
|
element = pop.elements[element](parent, ...)
|
||||||
if parent then
|
if parent then
|
||||||
insert(parent.child, element)
|
insert(parent.child, element)
|
||||||
|
@ -51,10 +51,30 @@ pop.load = ->
|
|||||||
pop.screen = pop.create("element", false)\setSize(graphics.getWidth!, graphics.getHeight!)
|
pop.screen = pop.create("element", false)\setSize(graphics.getWidth!, graphics.getHeight!)
|
||||||
print "created \"pop.screen\""
|
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)
|
-- creates an element with specified parent (parent can be false)
|
||||||
pop.create = (element, parent=pop.screen, ...) ->
|
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
|
--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, ...)
|
element = pop.elements[element](parent, ...)
|
||||||
|
else
|
||||||
|
element = pop.elements[element](pop.screen, parent, ...)
|
||||||
|
|
||||||
if parent
|
if parent
|
||||||
insert parent.child, element
|
insert parent.child, element
|
||||||
|
Loading…
Reference in New Issue
Block a user