Ejemplo n.º 1
0
        public override void update(float t)
        {
            CC3Node node      = (CC3Node)_target;
            bool    stackable = ccConfig.CC_ENABLE_STACKABLE_ACTIONS;
            Vector3 toPos     = node.position3D;

            if (stackable)
            {
                Vector3 currentPos = node.position3D;
                Vector3 diff       = currentPos - _previousPos;
                _startPos = _startPos + diff;
                Vector3 newPos = _startPos + _positionDelta * t;
                toPos        = newPos;
                _previousPos = newPos;
            }
            else
            {
                toPos = _startPos + _positionDelta * t;
            }
            if ((_masks & XMASK) != 0)
            {
                node.positionX = toPos.x;
            }
            if ((_masks & YMASK) != 0)
            {
                node.positionY = toPos.y;
            }
            if ((_masks & ZMASK) != 0)
            {
                node.positionZ = toPos.z;
            }
        }
Ejemplo n.º 2
0
        public override void startWithTarget(object aTarget)
        {
            base.startWithTarget(aTarget);
            CC3Node node = (CC3Node)_target;

            _startAngle = new Vector3(node.rotationX, node.rotationY, node.rotation);
        }
Ejemplo n.º 3
0
        public override void update(float t)
        {
            // Sin jump. Less realistic
            //	ccTime y = _height * fabsf( sinf(t * (CGFloat)M_PI * _jumps ) );
            //	y += _delta.y * dt;
            //	// parabolic jump (since v0.8.2)
            float   frac  = t * _jumps % 1.0f;
            float   y     = _height * 4 * frac * (1 - frac);
            Vector3 delta = y * _axis;

            delta += new Vector3(_delta.x * Math.Abs(_axis.x), _delta.y * Math.Abs(_axis.y), _delta.z * Math.Abs(_axis.z)) * t;

            CC3Node node      = (CC3Node)_target;
            bool    stackable = ccConfig.CC_ENABLE_STACKABLE_ACTIONS;

            if (stackable)
            {
                Vector3 currentPos = node.position3D;

                Vector3 diff = currentPos - _previousPos;
                _startPosition = diff + _startPosition;

                Vector3 newPos = _startPosition + delta;
                node.position3D = newPos;

                _previousPos = newPos;
            }
            else
            {
                node.position3D = _startPosition + delta;
            }
        }
Ejemplo n.º 4
0
        public override void startWithTarget(object aTarget)
        {
            NSUtils.Assert(aTarget is CC3Node, "CC3Rotate only supports with CC3Node, and target is {0}.", aTarget);
            base.startWithTarget(aTarget);

            //Calculate angle
            CC3Node node = (CC3Node)_target;

            _startAngle = new Vector3(node.rotationX, node.rotationY, node.rotation);

            if (FloatUtils.Big(_startAngle.x, 0))
            {
                _startAngle.x = _startAngle.x % 360.0f;
            }
            else
            {
                _startAngle.x = _startAngle.x % -360.0f;
            }

            if (FloatUtils.Big(_startAngle.y, 0))
            {
                _startAngle.y = _startAngle.y % 360.0f;
            }
            else
            {
                _startAngle.y = _startAngle.y % -360.0f;
            }

            if (FloatUtils.Big(_startAngle.z, 0))
            {
                _startAngle.z = _startAngle.z % 360.0f;
            }
            else
            {
                _startAngle.z = _startAngle.z % -360.0f;
            }



            _diffAngle = _dstAngle - _startAngle;
            if (FloatUtils.Big(_diffAngle.x, 180))
            {
                _diffAngle.x -= 360;
            }
            if (FloatUtils.Small(_diffAngle.x, -180))
            {
                _diffAngle.x += 360;
            }

            if (FloatUtils.Big(_diffAngle.y, 180))
            {
                _diffAngle.y -= 360;
            }
            if (FloatUtils.Small(_diffAngle.y, -180))
            {
                _diffAngle.y += 360;
            }

            if (FloatUtils.Big(_diffAngle.z, 180))
            {
                _diffAngle.z -= 360;
            }
            if (FloatUtils.Small(_diffAngle.z, -180))
            {
                _diffAngle.z += 360;
            }
        }
Ejemplo n.º 5
0
 /** initializes the action */
 public void initWithTarget(CC3Node fNode)
 {
     base.init();
     _followedNode = fNode;
 }
Ejemplo n.º 6
0
 /** creates the action with no boundary set */
 public CC3Follow(CC3Node fNode)
 {
     initWithTarget(fNode);
 }