Big() public static method

public static Big ( float a, float b ) : bool
a float
b float
return bool
コード例 #1
0
        public override void startWithTarget(object aTarget)
        {
            base.startWithTarget(aTarget);

            //Calculate angle
            _startAngle = ((CCNode)_target).rotation;
            if (FloatUtils.Big(_startAngle, 0))
            {
                _startAngle = _startAngle % 360.0f;
            }
            else
            {
                _startAngle = _startAngle % -360.0f;
            }

            _diffAngle = _dstAngle - _startAngle;
            if (FloatUtils.Big(_diffAngle, 180))
            {
                _diffAngle -= 360;
            }
            if (FloatUtils.Small(_diffAngle, -180))
            {
                _diffAngle += 360;
            }
        }
コード例 #2
0
 public override void update(float t)
 {
     if (!this.isDone())
     {
         float slice = 1.0f / _times;
         float m     = t % slice;
         (_target as CCNode).visible = FloatUtils.Big(m, slice / 2);
     }
 }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
 void showState()
 {
     if (_displayStats)
     {
         _frames++;
         _accumDt += _dt;
         if (FloatUtils.Big(_accumDt, ccConfig.CC_DIRECTOR_STATS_INTERVAL))
         {
             _frameRate = _frames / _accumDt;
             _frames    = 0;
             _accumDt   = 0;
         }
         _ccNumberOfDrawsToShow = _ccNumberOfDraws;
     }
     _ccNumberOfDraws = 0;
 }
コード例 #5
0
        // 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);
            }
        }
コード例 #6
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));
            }
        }
コード例 #7
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;
            }
        }
コード例 #8
0
        static void CheckSemiTransparentSprite(NSDictionary dictionary, Texture2D texture)
        {
            NSDictionary metadataDict = dictionary.objectForKey <NSDictionary>("metadata");
            NSDictionary framesDict   = dictionary.objectForKey <NSDictionary>("frames");

            // get the format
            int format = 0;

            if (metadataDict != null)
            {
                format = metadataDict.objectForKey <int> ("format");
            }

            // get texture size
            Vector2 textureSize = new Vector2(texture.width, texture.height);

            // check the format
            NSUtils.Assert(format >= 0 && format <= 3, @"cocos2d: WARNING: format is not supported for CCSpriteFrameCache addSpriteFramesWithDictionary:texture:");

            // SpriteFrame info
            Rect rect           = new Rect();
            bool textureRotated = false;

            // add real frames
            var enumerator = framesDict.GetEnumerator();

            while (enumerator.MoveNext())
            {
                KeyValuePair <object, object> frameDictKeyValue = enumerator.Current;
                NSDictionary frameDict = (NSDictionary)frameDictKeyValue.Value;
                if (format == 0)
                {
                    float x  = frameDict.objectForKey <float>("x");
                    float y  = frameDict.objectForKey <float>("y");
                    float w  = frameDict.objectForKey <float>("width");
                    float h  = frameDict.objectForKey <float>("height");
                    int   ow = frameDict.objectForKey <int>("originalWidth");
                    int   oh = frameDict.objectForKey <int>("originalHeight");
                    // check ow/oh
                    if (ow == 0 || oh == 0)
                    {
                        CCDebug.Warning("cocos2d: WARNING: originalWidth/Height not found on the CCSpriteFrame. AnchorPoint won't work as expected. Regenerate the .plist");
                    }

                    // abs ow/oh
                    ow = Math.Abs(ow);
                    oh = Math.Abs(oh);

                    // set frame info
                    rect           = new Rect(x, y, w, h);
                    textureRotated = false;
                }
                else if (format == 1 || format == 2)
                {
                    Rect frame   = ccUtils.RectFromString(frameDict.objectForKey <string>("frame"));
                    bool rotated = false;

                    // rotation
                    if (format == 2)
                    {
                        rotated = frameDict.objectForKey <bool>("rotated");
                    }

                    // set frame info
                    rect           = frame;
                    textureRotated = rotated;
                }
                else if (format == 3)
                {
                    // get values
                    Vector2 spriteSize      = ccUtils.PointFromString(frameDict.objectForKey <string>("spriteSize"));
                    Rect    textureRect     = ccUtils.RectFromString(frameDict.objectForKey <string>("textureRect"));
                    bool    textureRotated_ = frameDict.objectForKey <bool>("textureRotated");


                    // set frame info
                    rect           = new Rect(textureRect.position.x, textureRect.position.y, spriteSize.x, spriteSize.y);
                    textureRotated = textureRotated_;
                }
                if (textureRotated)
                {
                    rect.size = new Vector2(rect.size.y, rect.size.x);
                }
                rect.y = textureSize.y - rect.y - rect.height;

                // add sprite frame
                int  rectX  = Mathf.RoundToInt(rect.xMin);
                int  rectY  = Mathf.RoundToInt(rect.yMin);
                int  rectW  = Mathf.RoundToInt(rect.width);
                int  rectH  = Mathf.RoundToInt(rect.height);
                bool isSemi = false;
                for (int x = 0; x < rectW; x++)
                {
                    for (int y = 0; y < rectH; y++)
                    {
                        Color color = texture.GetPixel(rectX + x, rectY + y);
                        if (FloatUtils.Big(color.a, 0) && FloatUtils.Small(color.a, 1))
                        {
                            isSemi = true;
                            break;
                        }
                    }
                    if (isSemi)
                    {
                        break;
                    }
                }
                frameDict.Add("semi", isSemi);
            }
        }
コード例 #9
0
        // Helper
        protected void updateTexture()
        {
            if (string.IsNullOrEmpty(_text))
            {
                _content.mesh.text = _text;
                return;
            }
            if (FloatUtils.EQ(_dimensions.x, 0))
            {
                _content.mesh.text = _text;
                Bounds  localBounds = getLocalbounds();
                Vector2 textSize    = ccUtils.UnitsToPixels(localBounds.size);
                this.contentSize = textSize;
            }
            else
            {
                StringBuilder finalText         = new StringBuilder();
                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.Append(tmpStr);
                        originalText      = originalText.Substring(i);
                        i                 = 0;
                        preEmptyCharIndex = -1;
                    }

                    _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.Append(tmpStr);
                        if (i < originalText.Length)
                        {
                            finalText.Append("\n");
                            originalText = originalText.Substring(i);
                            i            = 0;
                        }
                    }
                    else if (i == originalText.Length)
                    {
                        tmpStr = originalText.Substring(0, i);
                        finalText.Append(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.ToString();
                Bounds  bounds   = getLocalbounds();
                Vector2 textSize = ccUtils.UnitsToPixels(bounds.size);
                this.contentSize = textSize;
            }
            _isContentDirty = true;
        }