From d8da8576e8321fd989cbb865c0e4d19d295a36b1 Mon Sep 17 00:00:00 2001 From: fgenesis Date: Sat, 28 Nov 2015 23:42:39 +0100 Subject: [PATCH] Fix moveToBack/moveToFront when used on objects that have a parent --- BBGE/RenderObject.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/BBGE/RenderObject.cpp b/BBGE/RenderObject.cpp index ae5faa2..6e79b4d 100644 --- a/BBGE/RenderObject.cpp +++ b/BBGE/RenderObject.cpp @@ -507,10 +507,10 @@ void RenderObject::moveToFront() { if(RenderObject *p = parent) { - if(p->children.size() && p->children[0] != this) + if(p->children.size() && p->children[p->children.size()-1] != this) { p->removeChild(this); - p->addChild(this, (ParentManaged)this->pm, RBP_NONE, CHILD_FRONT); + p->addChild(this, (ParentManaged)this->pm, RBP_NONE, CHILD_BACK); // To back of list -> rendered on top } } else if (layer != -1) @@ -521,10 +521,10 @@ void RenderObject::moveToBack() { if(RenderObject *p = parent) { - if(p->children.size() && p->children[p->children.size()-1] != this) + if(p->children.size() && p->children[0] != this) { p->removeChild(this); - p->addChild(this, (ParentManaged)this->pm, RBP_NONE, CHILD_BACK); + p->addChild(this, (ParentManaged)this->pm, RBP_NONE, CHILD_FRONT); // To front of list -> rendered first, below everything else } } else if (layer != -1)