Exemple #1
0
        public override void update(float t)
        {
            float newT = 0;

            if (FloatUtils.EQ(t, 0) || FloatUtils.EQ(t, 1))
            {
                newT = t;
            }

            else
            {
                float s = _period / 4;
                t    = t - 1;
                newT = -Mathf.Pow(2, 10 * t) * Mathf.Sin((t - s) * (Mathf.PI * 2) / _period);
            }
            _inner.update(newT);
        }
Exemple #2
0
        public override void update(float t)
        {
            // prevents rouding errors
            if (!FloatUtils.EQ(t, 1) && !FloatUtils.EQ(t, 0))
            {
                t *= 2;
                if (FloatUtils.Small(t, 1))
                {
                    t = 0.5f * Mathf.Pow(2, 10 * (t - 1));
                }
                else
                {
                    t = 0.5f * (-Mathf.Pow(2, -10 * (t - 1)) + 2);
                }
            }

            _inner.update(t);
        }
Exemple #3
0
        // Needed for BridgeSupport
        public override void update(float t)
        {
            if (FloatUtils.Small(t, 0.5f))
            {
                t = Mathf.Pow(t * _intersetValue, _polynomialOrder);
            }
            else
            {
                if (_hasInflection)
                {
                    t = Mathf.Pow((t - 1.0f) * _intersetValue, _polynomialOrder) + 1.0f;
                }
                else
                {
                    t = -Mathf.Pow((t - 1.0f) * _intersetValue, _polynomialOrder) + 1.0f;
                }
            }

            _inner.update(t);
        }
        public static CGAffineTransform Invert(CGAffineTransform xform)
        {
            CGAffineTransform result;
            float             determinant;

            determinant = xform.a * xform.d - xform.c * xform.b;
            if (FloatUtils.EQ(determinant, 0))
            {
                return(xform);
            }

            result.a  = xform.d / determinant;
            result.b  = -xform.b / determinant;
            result.c  = -xform.c / determinant;
            result.d  = xform.a / determinant;
            result.tx = (-xform.d * xform.tx + xform.c * xform.ty) / determinant;
            result.ty = (xform.b * xform.tx - xform.a * xform.ty) / determinant;

            return(result);
        }
        protected float bounceTime(float t)
        {
            if (FloatUtils.Small(t, 1 / 2.75f))
            {
                return(7.5625f * t * t);
            }
            else if (FloatUtils.Small(t, 2 / 2.75f))
            {
                t -= 1.5f / 2.75f;
                return(7.5625f * t * t + 0.75f);
            }
            else if (FloatUtils.Small(t, 2.5f / 2.75f))
            {
                t -= 2.25f / 2.75f;
                return(7.5625f * t * t + 0.9375f);
            }

            t -= 2.625f / 2.75f;
            return(7.5625f * t * t + 0.984375f);
        }
        public override void update(float t)
        {
            float newT;

            // prevents possible rounding errors
            if (FloatUtils.EQ(t, 0) || FloatUtils.EQ(t, 1))
            {
                newT = t;
            }
            else if (FloatUtils.Small(t, 0.5f))
            {
                t    = t * 2;
                newT = (1 - bounceTime(1 - t)) * 0.5f;
            }
            else
            {
                newT = bounceTime(t * 2 - 1) * 0.5f + 0.5f;
            }

            _inner.update(newT);
        }
        // issue #80. Instead of hooking step:, hook update: since it can be called by any
        // container action like CCRepeat, CCSequence, CCEase, etc..
        public override void update(float dt)
        {
            if (FloatUtils.EB(dt, _nextDt))
            {
                while (FloatUtils.Big(dt, _nextDt) && _total < _times)
                {
                    _innerAction.update(1.0f);
                    _total++;

                    _innerAction.stop();
                    _innerAction.startWithTarget(_target);
                    _nextDt += _innerAction.duration / _duration;
                }

                // fix for issue #1288, incorrect end value of repeat
                if (FloatUtils.EB(dt, 1.0f) && _total < _times)
                {
                    _total++;
                }

                // don't set a instantaction back or update it, it has no use because it has no duration
                if (!_isActionInstant)
                {
                    if (_total == _times)
                    {
                        _innerAction.update(1);
                        _innerAction.stop();
                    }
                    else
                    {
                        // issue #390 prevent jerk, use right update
                        _innerAction.update(dt - (_nextDt - _innerAction.duration / _duration));
                    }
                }
            }
            else
            {
                _innerAction.update((dt * _times) % 1.0f);
            }
        }
Exemple #8
0
        public void initWithAction(CCActionFiniteTime one, CCActionFiniteTime two)
        {
            NSUtils.Assert(one != null && two != null, "Sequence: arguments must be non-nil");
            NSUtils.Assert(one != _one && one != _two, "Spawn: reinit using same parameters is not supported");
            NSUtils.Assert(two != _two && two != _one, "Spawn: reinit using same parameters is not supported");

            float d1 = one.duration;
            float d2 = two.duration;

            base.initWithDuration(Mathf.Max(d1, d2));
            _one = one;
            _two = two;

            if (FloatUtils.Big(d1, d2))
            {
                _two = CCSequence.Actions(two, new CCDelayTime(d1 - d2));
            }
            else if (d1 < d2)
            {
                _one = CCSequence.Actions(one, new CCDelayTime(d2 - d1));
            }
        }
        //-------------update------------

        /** 'update' the scheduler.
         * You should NEVER call this method, unless you know what you are doing.
         */
        public void update(float dt)
        {
            if (_paused)
            {
                return;
            }
            updateHashLocked = true;
            if (!FloatUtils.EQ(_timeScale, 1.0f))
            {
                dt *= _timeScale;
            }

            // Iterate all over the Updates selectors
            // updates with priority < 0
            {
                for (utNode <tListEntry> tmp = updatesNeg.head; tmp != null; tmp = tmp.next)
                {
                    utNode <tListEntry> entry = tmp;
                    if (!entry.obj.paused && !entry.obj.markedForDeletion)
                    {
                        entry.obj.impMethod.Invoke(dt);
                    }
                }
            }
            // updates with priority == 0
            {
                for (utNode <tListEntry> tmp = updates0.head; tmp != null; tmp = tmp.next)
                {
                    utNode <tListEntry> entry = tmp;
                    if (!entry.obj.paused && !entry.obj.markedForDeletion)
                    {
                        entry.obj.impMethod.Invoke(dt);
                    }
                }
            }
            // updates with priority > 0
            {
                for (utNode <tListEntry> tmp = updatesPos.head; tmp != null; tmp = tmp.next)
                {
                    utNode <tListEntry> entry = tmp;
                    if (!entry.obj.paused && !entry.obj.markedForDeletion)
                    {
                        entry.obj.impMethod.Invoke(dt);
                    }
                }
            }

//			 Iterate all over the custom selectors (CCTimers)
            if (hashForTimers.Any())
            {
                var enumerator = new Dictionary <int, tHashTimerEntry>(hashForTimers).GetEnumerator();
                while (enumerator.MoveNext())
                {
                    var elt = enumerator.Current.Value;
                    currentTarget         = elt;
                    currentTargetSalvaged = false;
                    if (!currentTarget.paused)
                    {
                        for (elt.timerIndex = 0; elt.timerIndex < elt.timers.Count; elt.timerIndex++)
                        {
                            elt.currentTimer         = elt.timers[elt.timerIndex];
                            elt.currentTimerSalvaged = false;
                            elt.currentTimer.update(dt);
                            elt.currentTimer = null;
                        }
                    }
                    if (currentTargetSalvaged && currentTarget.timers.Count == 0)
                    {
                        removeHashElement(currentTarget);
                    }
                }
            }


            for (utNode <tListEntry> tmp = updatesNeg.head; tmp != null; tmp = tmp.next)
            {
                utNode <tListEntry> entry = tmp;
                if (entry.obj.markedForDeletion)
                {
                    removeUpdatesFromHash(entry);
                }
            }

            for (utNode <tListEntry> tmp = updates0.head; tmp != null; tmp = tmp.next)
            {
                utNode <tListEntry> entry = tmp;
                if (entry.obj.markedForDeletion)
                {
                    removeUpdatesFromHash(entry);
                }
            }


            for (utNode <tListEntry> tmp = updatesPos.head; tmp != null; tmp = tmp.next)
            {
                utNode <tListEntry> entry = tmp;
                if (entry.obj.markedForDeletion)
                {
                    removeUpdatesFromHash(entry);
                }
            }
            updateHashLocked = false;
            currentTarget    = null;
        }
Exemple #10
0
 public override void update(float t)
 {
     _inner.update(FloatUtils.EQ(t, 0) ? 0 : Mathf.Pow(2, 10 * (t / 1 - 1)) /* - 1 * 0.001f */);
 }
		public void OnUpdate(CADisplayLink sender) {
			bool hasTouchesBegan = false;
			bool hasTouchesMoved = false;
			bool hasTouchesEnded = false;
			bool hasTouchesCancelled = false;
			int touchCount = Input.touchCount;
			if (touchCount > 0) {
				int count = Input.touches.Length;
				for (int i=0; i<count; i++) {
					Touch touch = Input.touches [i];
					UITouch uiTouch = new UITouch ();
					uiTouch.fingerId = touch.fingerId;
					uiTouch.phase = touch.phase;
					uiTouch.location = Camera.main.ScreenToWorldPoint (touch.position) * PIXEL_PER_UNIT;
					uiTouch.tapCount = touch.tapCount;
					uiTouch.timestamp = DateTime.Now;
					if (touch.phase == TouchPhase.Began) {
						touchesBegan.Add (uiTouch);
						hasTouchesBegan = true;
					} else if (touch.phase == TouchPhase.Moved) {
						touchesMoved.Add (uiTouch);
						hasTouchesMoved = true;
					} else if (touch.phase == TouchPhase.Ended) {
						touchesEnded.Add (uiTouch);
						hasTouchesEnded = true;
					} else if (touch.phase == TouchPhase.Canceled) {
						touchesCancelled.Add (uiTouch);
						hasTouchesCancelled = true;
					}
				} 
			} else {
				#if UNITY_EDITOR
				#if UNITY_IOS || UNITY_ANDROID || UNITY_WP8 || UNITY_WP8_1
				if(Input.GetMouseButtonDown(0)){
					UITouch uiTouch = new UITouch();
					uiTouch.fingerId = UITouch.SINGLE_TOUCH_ID;
					uiTouch.phase = TouchPhase.Began;
					uiTouch.location = Camera.main.ScreenToWorldPoint(Input.mousePosition) * PIXEL_PER_UNIT;
					uiTouch.tapCount = 1;
					uiTouch.timestamp = DateTime.Now;
					
					touchesBegan.Add (uiTouch);
					hasTouchesBegan = true;
				}else if(Input.GetMouseButtonUp(0)){
					UITouch uiTouch = new UITouch();
					uiTouch.fingerId = UITouch.SINGLE_TOUCH_ID;
					uiTouch.phase = TouchPhase.Ended;
					uiTouch.location = Camera.main.ScreenToWorldPoint(Input.mousePosition) * PIXEL_PER_UNIT;
					uiTouch.tapCount = 1;
					uiTouch.timestamp = DateTime.Now;
					
					touchesEnded.Add (uiTouch);
					hasTouchesEnded = true;
				}else if(Input.GetMouseButton(0)){
					UITouch uiTouch = new UITouch();
					uiTouch.fingerId = UITouch.SINGLE_TOUCH_ID;
					uiTouch.phase = TouchPhase.Moved;
					uiTouch.location = Camera.main.ScreenToWorldPoint(Input.mousePosition) * PIXEL_PER_UNIT;
					uiTouch.tapCount = 1;
					uiTouch.timestamp = DateTime.Now;
					
					touchesMoved.Add (uiTouch);
					hasTouchesMoved = true;
				}
				#endif
				#endif
			}
			if (hasTouchesBegan)
				_rootViewController.view.touchesBegan (touchesBegan);
			if (hasTouchesMoved)
				_rootViewController.view.touchesMoved (touchesMoved);
			if (hasTouchesEnded)
				_rootViewController.view.touchesEnded (touchesEnded);
			if (hasTouchesCancelled)
				_rootViewController.view.touchesCancelled (touchesCancelled);
			touchesBegan.Clear ();
			touchesMoved.Clear ();
			touchesEnded.Clear ();
			touchesCancelled.Clear ();
			
			#if UNITY_STANDALONE || UNITY_WEBGL
			if (Input.GetMouseButtonDown (0)) {
				NSEvent nsevent = getMouseEvent ();
				_rootViewController.view.mouseDown (nsevent);
			} else if (Input.GetMouseButtonUp (0)) {
				NSEvent nsevent = getMouseEvent ();
				_rootViewController.view.mouseUp (nsevent);
			} else if (Input.GetMouseButton (0)) {
				NSEvent nsevent = getMouseEvent ();
				_rootViewController.view.mouseDragged (nsevent);
			} else if (Input.GetMouseButtonDown (1)) {
				NSEvent nsevent = getMouseEvent ();
				_rootViewController.view.rightMouseDown (nsevent);
			} else if (Input.GetMouseButtonUp (1)) {
				NSEvent nsevent = getMouseEvent ();
				_rootViewController.view.rightMouseUp (nsevent);
			} else if (Input.GetMouseButton (1)) {
				NSEvent nsevent = getMouseEvent ();
				_rootViewController.view.rightMouseDragged (nsevent);
			} else if (Input.GetMouseButtonDown (2)) {
				NSEvent nsevent = getMouseEvent ();
				_rootViewController.view.otherMouseDown (nsevent);
			} else if (Input.GetMouseButtonUp (2)) {
				NSEvent nsevent = getMouseEvent ();
				_rootViewController.view.otherMouseUp (nsevent);
			} else if (Input.GetMouseButton (2)) {
				NSEvent nsevent = getMouseEvent ();
				_rootViewController.view.otherMouseDragged (nsevent);
			}else{
				float d = Input.GetAxis("Mouse ScrollWheel");
				if(!FloatUtils.EQ(d, 0)){
					NSEvent wheelEvt = getMouseEvent();
					wheelEvt.mouseWheelDelta = d;
					_rootViewController.view.scrollWheel(wheelEvt);
				}
				float dx = Input.GetAxis("Mouse X");
				float dy = Input.GetAxis("Mouse Y");
				if(!FloatUtils.EQ(dx, 0) || !FloatUtils.EQ(dy, 0)){
					NSEvent nsevent = getMouseEvent ();
					nsevent.mouseDelta = new Vector2(dx, dy) * PIXEL_PER_UNIT;
					_rootViewController.view.mouseMoved(nsevent);
				}
			}
			//Keybaord Events
			keyboardEvent();

			#endif
		}
Exemple #12
0
 public override void update(float t)
 {
     _inner.update(FloatUtils.EQ(t, 1) ? 1 : (-Mathf.Pow(2, -10 * t / 1) + 1));
 }
        public static CCTMXMap Parse(string file, NSDictionary tilesetCaches = null)
        {
            string      text   = LoadText(file);
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(text);
            XmlNodeList nodeList = xmlDoc.DocumentElement.ChildNodes;

            // get mapWidth, mapHeight, tileWidth, tileHeight
            XmlNode mapNode = xmlDoc.DocumentElement;

            float version = float.Parse(mapNode.Attributes["version"].InnerText);

            if (!FloatUtils.EQ(version, 1.0f))
            {
                CCDebug.Warning("cocos2d:CCTMXMap: Found {0} tmx file, but only 1.0 version was tested.", version);
            }

            string dir = file.Replace(Path.GetFileName(file), "");

            CCTMXMap map = new CCTMXMap();

            map.fileName   = file;
            map.cols       = int.Parse(mapNode.Attributes["width"].InnerText);
            map.rows       = int.Parse(mapNode.Attributes["height"].InnerText);
            map.tileWidth  = int.Parse(mapNode.Attributes["tilewidth"].InnerText);
            map.tileHeight = int.Parse(mapNode.Attributes["tileheight"].InnerText);

            Dictionary <int, string> gidToFiles = new Dictionary <int, string> (256);
            Dictionary <int, Dictionary <string, string> > gidToTileProperties = new Dictionary <int, Dictionary <string, string> > (256);
            List <CCTMXLayer> layers = new List <CCTMXLayer> (8);


            var enumerator = nodeList.GetEnumerator();

            while (enumerator.MoveNext())
            {
                XmlNode nodeData = (XmlNode)enumerator.Current;
                if (nodeData.Name == "tileset")
                {
                    ParseTileset(nodeData, gidToFiles, gidToTileProperties, dir, tilesetCaches);
                }
                else if (nodeData.Name == "layer")
                {
                    CCTMXLayer layer = ParseLayer(nodeData, map.cols, map.rows, gidToFiles, gidToTileProperties);
                    layers.Add(layer);
                }
                else if (nodeData.Name == "objectgroup")
                {
                    CCTMXLayer layer = ParseObjectGroup(nodeData, map.cols, map.rows, map.tileWidth, map.tileHeight, gidToFiles, gidToTileProperties);
                    layers.Add(layer);
                }
                else if (nodeData.Name == "properties")
                {
                    if (map.properties == null)
                    {
                        map.properties = new Dictionary <string, string>();
                    }
                    ParseProperties(nodeData, map.properties);
                }
            }
            map.gidToFiles          = gidToFiles;
            map.gidToTileProperties = gidToTileProperties;
            map.layers = layers.ToArray();
            return(map);
        }
 protected override CCAction reverseImpl()
 {
     return(new CCShake(this.duration, amplitude, dampening, FloatUtils.EQ(shakeInterval, 0) ? 0 : Mathf.RoundToInt(1 / shakeInterval)));
 }
        public override void update(float t)
        {
            int   found = 0;
            float new_t = 0;

            CCAction action0 = _actions [0];
            CCAction action1 = _actions [1];

            if (FloatUtils.Small(t, _split))
            {
                // action[0]
                found = 0;
                if (!FloatUtils.EQ(_split, 0))
                {
                    new_t = t / _split;
                }
                else
                {
                    new_t = 1;
                }
            }
            else
            {
                // action[1]
                found = 1;
                if (FloatUtils.EQ(_split, 1))
                {
                    new_t = 1;
                }
                else
                {
                    new_t = (t - _split) / (1 - _split);
                }
            }

            if (found == 1)
            {
                if (_last == -1)
                {
                    // action[0] was skipped, execute it.
                    action0.startWithTarget(_target);
                    action0.update(1.0f);
                    action0.stop();
                }
                else if (_last == 0)
                {
                    // switching to action 1. stop action 0.
                    action0.update(1.0f);
                    action0.stop();
                }
            }
            else if (found == 0 && _last == 1)
            {
                // Reverse mode ?
                // XXX: Bug. this case doesn't contemplate when _last==-1, found=0 and in "reverse mode"
                // since it will require a hack to know if an action is on reverse mode or not.
                // "step" should be overriden, and the "reverseMode" value propagated to inner Sequences.
                action1.update(0);
                action1.stop();
            }

            // Last action found and it is done.
            if (found == _last && _actions[found].isDone())
            {
                return;
            }

            // New action. Start it.
            if (found != _last)
            {
                _actions[found].startWithTarget(_target);
            }

            _actions[found].update(new_t);
            _last = found;
        }
Exemple #16
0
 /** returns YES if the action has finished */
 public override bool isDone()
 {
     return(FloatUtils.EB(_elapsed, _duration));
 }
        public override void ccTouchMoved(UITouch touch)
        {
            if (scrollTouch_ != touch)
            {
                return;
            }

            Vector2 touchPoint = this.convertTouchToNodeSpace(touch);

            touchPoint = this.convertToWorldSpace(touchPoint);


            // If finger is dragged for more distance then minimum - start sliding and cancel pressed buttons.
            // Of course only if we not already in sliding mode
            if ((state_ != kCCScrollLayerState.Sliding) &&
                (Mathf.Abs(touchPoint.x - startSwipe_) >= this.minimumTouchLengthToSlide))
            {
                state_ = kCCScrollLayerState.Sliding;

                // Avoid jerk after state change.
                startSwipe_ = touchPoint.x;

                if (this.stealTouches)
                {
                    this.claimTouch(touch);
                }
                if (this.delegate_ != null)
                {
                    this.delegate_.scrollLayerDraging(this);
                }
            }

            if (state_ == kCCScrollLayerState.Sliding)
            {
                float desiredX = (-currentScreen_ * (this.contentSize.x - this.pagesWidthOffset)) + touchPoint.x - startSwipe_;
                int   page     = this.pageNumberForPosition(new Vector2(desiredX, 0));
                float offset   = desiredX - this.positionForPageWithNumber(page).x;
                if ((page == 0 && FloatUtils.Big(offset, 0)) || (page == layers_.Count - 1 && FloatUtils.Small(offset, 0)))
                {
                    offset -= marginOffset_ * offset / CCDirector.sharedDirector.winSize.x;
                }
                else
                {
                    offset = 0;
                }
                this.position = new Vector2(desiredX - offset, 0);
            }
        }
        // Helper
        protected bool updateTexture()
        {
            if (FloatUtils.EQ(_dimensions.x, 0) || FloatUtils.EQ(_dimensions.y, 0))
            {
                _content.mesh.text = _text;
                Bounds  localBounds = getLocalbounds();
                Vector2 textSize    = ccUtils.UnitsToPixels(localBounds.size);
                this.contentSize = textSize;
            }
            else
            {
                string finalText         = "";
                string originalText      = _text;
                int    preEmptyCharIndex = -1;
                for (int i = 1; i <= originalText.Length; i++)
                {
                    char c = originalText[i - 1];
                    if (char.IsWhiteSpace(c))
                    {
                        preEmptyCharIndex = i - 1;
                    }
                    string tmpStr = originalText.Substring(0, i);
                    if (c == '\n')
                    {
                        finalText   += tmpStr;
                        originalText = originalText.Substring(i);
                        i            = 0;
                    }

                    _content.mesh.text = tmpStr;
                    Bounds  localBounds = getLocalbounds();
                    Vector2 csize       = ccUtils.UnitsToPixels(localBounds.size);
                    if (FloatUtils.Big(csize.x, _dimensions.x))
                    {
                        if (preEmptyCharIndex == -1)
                        {
                            tmpStr = originalText.Substring(0, i);
                        }
                        else
                        {
                            tmpStr            = originalText.Substring(0, preEmptyCharIndex);
                            i                 = preEmptyCharIndex + 1;
                            preEmptyCharIndex = -1;
                        }
                        finalText += tmpStr;
                        if (i < originalText.Length)
                        {
                            finalText   += "\n";
                            originalText = originalText.Substring(i);
                            i            = 0;
                        }
                    }
                    else if (i == originalText.Length)
                    {
                        tmpStr     = originalText.Substring(0, i);
                        finalText += tmpStr;
                        break;
                    }

//					string tmpStr = originalText.Substring(0, i);
//					_content.mesh.text = tmpStr;
//					Vector2 csize = _content.renderer.bounds.size;
//					csize = ccUtils.UnitsToPixels(csize);
//					if(FloatUtils.Small(csize.x , _dimensions.x) || i==1){
//						tmpStr = originalText.Substring(0, i);
//						finalText += tmpStr;
//						if(i<originalText.Length){
//							finalText += "\n";
//							originalText = originalText.Substring(i);
//							i = originalText.Length+1;
//						}else{
//							break;
//						}
//					}
                }
                _content.mesh.text = finalText;
                this.contentSize   = _dimensions;
            }
            _isContentDirty = true;

            return(true);
        }
        public virtual void updateTransform()
        {
            if (_isUpdateTransformDirty)
            {
                //position

//				CGAffineTransform tmpAffine = nodeToParentTransform();
//				Vector2 pInParent = CGAffineTransform.CGPointApplyAffineTransform(_anchorPointInPixels, tmpAffine);
//				Vector2 pInUIUnits = ccUtils.PixelsToUnits (pInParent);
//				transform.localPosition = new Vector3 (pInUIUnits.x, pInUIUnits.y, transform.localPosition.z);

//				if(_parent!=null && _parent.ignoreAnchorPointForPosition){
//					CGAffineTransform tmpAffine = _parent.nodeToWorldTransform ();
//					Vector2 pInWorld = CGAffineTransform.CGPointApplyAffineTransform (_position, tmpAffine);
//					Vector2 pInUI = CCDirector.sharedDirector.convertToUI (pInWorld);
//					Vector2 pInUIUnits = ccUtils.PixelsToUnits (pInUI);
//
//					transform.position = new Vector3 (pInUIUnits.x, pInUIUnits.y, 0);
//
//					Vector3 localPos = transform.localPosition;
//					localPos.z = -_positionZ / UIWindow.PIXEL_PER_UNIT;
//					transform.localPosition = localPos;
//				}else{
//					Vector2 pInParentAR = _position;
//					if(_parent==null)
//						pInParentAR = CCDirector.sharedDirector.convertToUI(pInParentAR);
//					else
//						pInParentAR -= _parent._anchorPointInPixels;
//					Vector2 pInUIUnits = ccUtils.PixelsToUnits (pInParentAR);
//					Vector3 pos = transform.localPosition;
//					pos.x = pInUIUnits.x;
//					pos.y = pInUIUnits.y;
//					pos.z = -_positionZ / UIWindow.PIXEL_PER_UNIT;
//					transform.localPosition = pos;
//				}

                Vector2 pInParentAR = _position;
                if (_parent != null && !_parent.ignoreAnchorPointForPosition)
                {
                    pInParentAR -= _parent._anchorPointInPixels;
                }
                Vector2 pInUIUnits = ccUtils.PixelsToUnits(pInParentAR);
                Vector3 pos        = transform.localPosition;
                pos.x = pInUIUnits.x;
                pos.y = pInUIUnits.y;
                pos.z = 0;
                transform.localPosition = pos;


                //rotation
                Vector3 rotation = transform.localEulerAngles;
                rotation.x = 0;
                rotation.z = -_rotation;
                rotation.y = 0;
                bool negativeScaleX = FloatUtils.Small(_scaleX, 0);
                bool negativeScaleY = FloatUtils.Small(_scaleY, 0);
                if (negativeScaleX && negativeScaleY)
                {
                    rotation.z = 180 - _rotation;
                }
                else if (negativeScaleX)
                {
                    rotation.y = 180;
                    rotation.z = _rotation;
                }
                else if (negativeScaleY)
                {
                    rotation.y = 180;
                    rotation.z = _rotation + 180;
                }

                transform.localEulerAngles = rotation;

                //scale
                transform.localScale = new Vector3(Mathf.Abs(_scaleX), Mathf.Abs(_scaleY), transform.localScale.z);

                _isUpdateTransformDirty = false;
            }
        }