We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
i implemented change order of sprite rendering
add Node2D public var z_order:Number = 0; private var isReorderChildDirty:Boolean = false;
add method Node2D
public function addChild(child:Node2D):Node2D { return addChildAt(child, children.length); } public function addChildZ(child:Node2D,z:Number):Node2D { isReorderChildDirty = true; return addChildAtZ(child, children.length,z); } public function addChildAtZ(child:Node2D,idx:uint,z:Number):Node2D { var existingIdx:int = getChildIndex(child); if(existingIdx != -1) { removeChildAt(existingIdx); } if(isBatchNode) { child.isBatchNode = isBatchNode; } child.z_order = z child.parent = this; child.setStageAndCamRef(_stage, camera); children.splice(idx, 0, child); return child; } public function addChildAt(child:Node2D, idx:uint):Node2D { return this.addChildAtZ(child,idx,children.length); } protected function sortAllChildren():void { //q-sort if (isReorderChildDirty) { if(children.length > 0) { quickSort(children,0,children.length - 1); isReorderChildDirty = false; } } } private function quickSort(vector:Vector.<Node2D>, left:Number, right:Number):void { var i:Number = 0,j:Number = 0; var node:Node2D = null; var tempNode:Node2D = null; i = left; j = right; // trace ('i<=j'+i+' <= '+ ' '+j); node = children[Math.round((left+right)*0.5)]; while (i<=j) { // trace('vector[i].z_order '+vector[i].z_order); // trace('node.z_order) '+node.z_order); while (vector[i].z_order < node.z_order) { i++; } while (vector[j].z_order > node.z_order) { j--; } if (i<=j) { tempNode = vector[i]; vector[i] = vector[j]; i++; vector[j] = tempNode; j--; } } if (left < j) { quickSort(vector, left, j); } if (i < right) { quickSort(vector, i, right); } return; } public function setZorder(z:Number):void { if (parent) { parent.reorderChild(z,this); } } public function reorderChild(z:Number,child:Node2D):void { if (!child) { return; } child.z_order = z; isReorderChildDirty = true; }
Modify method Node2D
internal function drawNode(context:Context3D, camera:Camera2D, parentMatrixChanged:Boolean, statsObject:StatsObject):void { var myMatrixChanged:Boolean = false; if(!_visible) { return; } sortAllChildren(); ...}
Modify method Scene2D
override internal function drawNode(context:Context3D, camera:Camera2D, parentMatrixChanged:Boolean, statsObject:StatsObject):void { sortAllChildren(); for each(var child:Node2D in children) { child.drawNode(context, camera, false, statsObject); }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
i implemented change order of sprite rendering
add Node2D
public var z_order:Number = 0;
private var isReorderChildDirty:Boolean = false;
add method Node2D
Modify method Node2D
Modify method Scene2D
The text was updated successfully, but these errors were encountered: