Example #1
0
        public LabelAtlasColorTest()
        {
            CCLabelAtlas label1 = new CCLabelAtlas("123 Test", "fonts/tuffy_bold_italic-charmap.png", 48, 64, ' ');

            AddChild(label1, 0, (int)TagSprite.kTagSprite1);
            label1.Position = new CCPoint(10, 100);
            label1.Opacity  = 200;

            CCLabelAtlas label2 = new CCLabelAtlas("0123456789", "fonts/tuffy_bold_italic-charmap.png", 48, 64, ' ');

            AddChild(label2, 0, (int)TagSprite.kTagSprite2);
            label2.Position = new CCPoint(10, 200);
            //label2.setColor( ccRED );
            label2.Color = ccRED;

            CCActionInterval fade = new CCFadeOut(1.0f);
            //CCActionInterval fade_in = fade.reverse();
            CCActionInterval   fade_in = null;
            CCFiniteTimeAction seq     = CCSequence.FromActions(fade, fade_in, null);
            CCAction           repeat  = new CCRepeatForever((CCActionInterval)seq);

            label2.RunAction(repeat);

            m_time = 0;

            //schedule( schedule_selector(LabelAtlasColorTest.step) ); //:@selector(step:)];
        }
 protected bool InitWithAction(CCActionInterval action)
 {
     Debug.Assert(action != null);
     m_pInnerAction = action;
     // Duration = action.Duration;
     return(true);
 }
Example #3
0
 protected bool InitWithAction(CCActionInterval action)
 {
     Debug.Assert(action != null);
     m_pInnerAction = action;
     // Duration = action.Duration;
     return true;
 }
Example #4
0
        protected bool InitWithAction(CCActionInterval action, float fRate)
        {
            Debug.Assert(action != null);

            m_pInnerAction = action;
            m_fSpeed = fRate;

            return true;
        }
Example #5
0
        protected bool InitWithAction(CCActionInterval action, float fRate)
        {
            Debug.Assert(action != null);

            m_pInnerAction = action;
            m_fSpeed       = fRate;

            return(true);
        }
Example #6
0
        private CCActionInterval GetEaseAction(CCActionInterval pAction, CCBEasingType nEasingTypeType, float fEasingOpt)
        {
            if (pAction is CCSequence)
            {
                return(pAction);
            }

            switch (nEasingTypeType)
            {
            case CCBEasingType.Linear:
                return(pAction);

            case CCBEasingType.Instant:
                return(new CCBEaseInstant(pAction));

            case CCBEasingType.CubicIn:
                return(new CCEaseIn(pAction, fEasingOpt));

            case CCBEasingType.CubicOut:
                return(new CCEaseOut(pAction, fEasingOpt));

            case CCBEasingType.CubicInOut:
                return(new CCEaseInOut(pAction, fEasingOpt));

            case CCBEasingType.BackIn:
                return(new CCEaseBackIn(pAction));

            case CCBEasingType.BackOut:
                return(new CCEaseBackOut(pAction));

            case CCBEasingType.BackInOut:
                return(new CCEaseBackInOut(pAction));

            case CCBEasingType.BounceIn:
                return(new CCEaseBounceIn(pAction));

            case CCBEasingType.BounceOut:
                return(new CCEaseBounceOut(pAction));

            case CCBEasingType.BounceInOut:
                return(new CCEaseBounceInOut(pAction));

            case CCBEasingType.ElasticIn:
                return(new CCEaseElasticIn(pAction, fEasingOpt));

            case CCBEasingType.ElasticOut:
                return(new CCEaseElasticOut(pAction, fEasingOpt));

            case CCBEasingType.ElasticInOut:
                return(new CCEaseElasticInOut(pAction, fEasingOpt));

            default:
                CCLog.Log("CCBReader: Unkown easing type {0}", nEasingTypeType);
                return(pAction);
            }
        }
Example #7
0
        public Atlas4()
        {
            m_time = 0;

            // Upper Label
            CCLabelBMFont label = new CCLabelBMFont("Bitmap Font Atlas", "fonts/bitmapFontTest.fnt");

            AddChild(label);

            CCSize s = CCDirector.SharedDirector.WinSize;

            label.Position    = new CCPoint(s.Width / 2, s.Height / 2);
            label.AnchorPoint = new CCPoint(0.5f, 0.5f);


            CCSprite BChar = (CCSprite)label.GetChildByTag(1);
            CCSprite FChar = (CCSprite)label.GetChildByTag(7);
            CCSprite AChar = (CCSprite)label.GetChildByTag(12);


            CCActionInterval rotate    = new CCRotateBy(2, 360);
            CCAction         rot_4ever = new CCRepeatForever(rotate);

            CCActionInterval scale = new CCScaleBy(2, 1.5f);
            //CCActionInterval scale_back = scale.reverse();
            CCActionInterval   scale_back  = null;
            CCFiniteTimeAction scale_seq   = CCSequence.FromActions(scale, scale_back, null);
            CCAction           scale_4ever = new CCRepeatForever((CCActionInterval)scale_seq);

            CCActionInterval jump       = new CCJumpBy(0.5f, new CCPoint(), 60, 1);
            CCAction         jump_4ever = new CCRepeatForever(jump);

            CCActionInterval   fade_out   = new CCFadeOut(1);
            CCActionInterval   fade_in    = new CCFadeIn(1);
            CCFiniteTimeAction seq        = CCSequence.FromActions(fade_out, fade_in, null);
            CCAction           fade_4ever = new CCRepeatForever((CCActionInterval)seq);

            BChar.RunAction(rot_4ever);
            BChar.RunAction(scale_4ever);
            FChar.RunAction(jump_4ever);
            AChar.RunAction(fade_4ever);


            // Bottom Label
            CCLabelBMFont label2 = new CCLabelBMFont("00.0", "fonts/bitmapFontTest.fnt");

            AddChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2);
            label2.Position = new CCPoint(s.Width / 2.0f, 80);

            CCSprite lastChar = (CCSprite)label2.GetChildByTag(3);

            lastChar.RunAction((CCAction)(rot_4ever.Copy()));

            //schedule( schedule_selector(Atlas4::step), 0.1f);
            base.Schedule(step, 0.1f);
        }
 protected virtual bool InitWithAction(CCAction pAction, float duration)
 {
     if (base.InitWithDuration(duration))
     {
         m_fRate = 1.0f;
         m_pOther = pAction as CCActionInterval;
         return true;
     }
     return false;
 }
Example #9
0
 protected virtual bool InitWithAction(CCAction pAction, float duration)
 {
     if (base.InitWithDuration(duration))
     {
         m_fRate  = 1.0f;
         m_pOther = pAction as CCActionInterval;
         return(true);
     }
     return(false);
 }
Example #10
0
        private CCActionInterval GetEaseAction(CCActionInterval pAction, CCBKeyframeEasing nEasingType, float fEasingOpt)
        {
            switch (nEasingType)
            {
            case CCBKeyframeEasing.Instant:
            case CCBKeyframeEasing.Linear:
                return(pAction);

            case CCBKeyframeEasing.CubicIn:
                return(new CCEaseIn(pAction, fEasingOpt));

            case CCBKeyframeEasing.CubicOut:
                return(new CCEaseOut(pAction, fEasingOpt));

            case CCBKeyframeEasing.CubicInOut:
                return(new CCEaseInOut(pAction, fEasingOpt));

            case CCBKeyframeEasing.BackIn:
                return(new CCEaseBackIn(pAction));

            case CCBKeyframeEasing.BackOut:
                return(new CCEaseBackOut(pAction));

            case CCBKeyframeEasing.BackInOut:
                return(new CCEaseBackInOut(pAction));

            case CCBKeyframeEasing.BounceIn:
                return(new CCEaseBounceIn(pAction));

            case CCBKeyframeEasing.BounceOut:
                return(new CCEaseBounceOut(pAction));

            case CCBKeyframeEasing.BounceInOut:
                return(new CCEaseBounceInOut(pAction));

            case CCBKeyframeEasing.ElasticIn:
                return(new CCEaseElasticIn(pAction, fEasingOpt));

            case CCBKeyframeEasing.ElasticOut:
                return(new CCEaseElasticOut(pAction, fEasingOpt));

            case CCBKeyframeEasing.ElasticInOut:
                return(new CCEaseElasticInOut(pAction, fEasingOpt));

            default:
                CCLog.Log("CCBReader: Unkown easing type {0}", nEasingType);
                return(pAction);
            }
        }
Example #11
0
        private void RunAction(CCNode node, CCBSequenceProperty pSeqProp, float fTweenDuration)
        {
            List <CCBKeyframe> keyframes = pSeqProp.Keyframes;
            int numKeyframes             = keyframes.Count;

            if (numKeyframes > 1)
            {
                // Make an animation!
                var actions = new List <CCFiniteTimeAction>();

                CCBKeyframe keyframeFirst = keyframes[0];
                float       timeFirst     = keyframeFirst.Time + fTweenDuration;

                if (timeFirst > 0)
                {
                    actions.Add(new CCDelayTime(timeFirst));
                }

                for (int i = 0; i < numKeyframes - 1; ++i)
                {
                    CCBKeyframe kf0 = keyframes[i];
                    CCBKeyframe kf1 = keyframes[i + 1];

                    CCActionInterval action = GetAction(kf0, kf1, pSeqProp.Name, node);
                    if (action != null)
                    {
                        // Apply easing
                        action = GetEaseAction(action, kf0.EasingType, kf0.EasingOpt);

                        actions.Add(action);
                    }
                }

                if (actions.Count > 1)
                {
                    CCFiniteTimeAction seq = new CCSequence(actions.ToArray());
                    node.RunAction(seq);
                }
                else
                {
                    node.RunAction(actions[0]);
                }
            }
        }
Example #12
0
 public CCSpeed(CCActionInterval action, float fRate)
 {
     InitWithAction(action, fRate);
 }
Example #13
0
 public CCEaseCustom(CCActionInterval pAction, Func<float, float> easeFunc)
 {
     InitWithAction(pAction, easeFunc);
 }
Example #14
0
 public void InitWithAction(CCActionInterval action, Func<float, float> easeFunc)
 {
     base.InitWithAction(action);
     m_EaseFunc = easeFunc;
 }
Example #15
0
 public CCEaseCustom(CCActionInterval pAction, Func <float, float> easeFunc)
 {
     InitWithAction(pAction, easeFunc);
 }
Example #16
0
 public CCEaseElasticOut(CCActionInterval pAction) : base(pAction, 0.3f)
 {
 }
Example #17
0
        private void SetAnimatedProperty(string pPropName, CCNode node, object pValue, float fTweenDuraion)
        {
            if (fTweenDuraion > 0)
            {
                // Create a fake keyframe to generate the action from
                var kf1 = new CCBKeyframe();
                kf1.Value      = pValue;
                kf1.Time       = fTweenDuraion;
                kf1.EasingType = CCBKeyframeEasing.Linear;

                // Animate
                CCActionInterval tweenAction = GetAction(null, kf1, pPropName, node);
                node.RunAction(tweenAction);
            }
            else
            {
                // Just set the value

                if (pPropName == "position")
                {
                    // Get position type
                    var array = (List <CCBValue>)GetBaseValue(node, pPropName);
                    var type  = (CCBPositionType)array[2].GetIntValue();

                    // Get relative position
                    var   value = (List <CCBValue>)pValue;
                    float x     = value[0].GetFloatValue();
                    float y     = value[1].GetFloatValue();

                    node.Position = CCBHelper.GetAbsolutePosition(new CCPoint(x, y), type, GetContainerSize(node.Parent), pPropName);
                }
                else if (pPropName == "scale")
                {
                    // Get scale type
                    var array = (List <CCBValue>)GetBaseValue(node, pPropName);
                    var type  = (CCBScaleType)array[2].GetIntValue();

                    // Get relative scale
                    var   value = (List <CCBValue>)pValue;
                    float x     = value[0].GetFloatValue();
                    float y     = value[1].GetFloatValue();

                    CCBHelper.SetRelativeScale(node, x, y, type, pPropName);
                }
                else
                {
                    // [node setValue:value forKey:name];

                    // TODO only handle rotation, opacity, displayFrame, color
                    if (pPropName == "rotation")
                    {
                        float rotate = ((CCBValue)pValue).GetFloatValue();
                        node.Rotation = rotate;
                    }
                    else if (pPropName == "opacity")
                    {
                        byte opacity = ((CCBValue)pValue).GetByteValue();
                        ((ICCRGBAProtocol)node).Opacity = opacity;
                    }
                    else if (pPropName == "displayFrame")
                    {
                        ((CCSprite)node).DisplayFrame = (CCSpriteFrame)pValue;
                    }
                    else if (pPropName == "color")
                    {
                        var color = (CCColor3BWapper)pValue;
                        ((CCSprite)node).Color = color.getColor();
                    }
                    else
                    {
                        CCLog.Log("unsupported property name is {0}", pPropName);
                        Debug.Assert(false, "unsupported property now");
                    }
                }
            }
        }
Example #18
0
 public CCRepeatForever(CCActionInterval action)
 {
     InitWithAction(action);
 }
 public CCEaseExponentialOut (CCActionInterval pAction) : base (pAction)
 { }
		public CCEaseElasticIn (CCActionInterval pAction) : base(pAction)
		{ }
 public CCEaseSineInOut(CCActionInterval pAction) : base(pAction)
 {
 }
 private CCActionInterval GetEaseAction(CCActionInterval pAction, CCBKeyframeEasing nEasingType, float fEasingOpt)
 {
     switch (nEasingType)
     {
         case CCBKeyframeEasing.Instant:
         case CCBKeyframeEasing.Linear:
             return pAction;
         case CCBKeyframeEasing.CubicIn:
             return new CCEaseIn(pAction, fEasingOpt);
         case CCBKeyframeEasing.CubicOut:
             return new CCEaseOut(pAction, fEasingOpt);
         case CCBKeyframeEasing.CubicInOut:
             return new CCEaseInOut(pAction, fEasingOpt);
         case CCBKeyframeEasing.BackIn:
             return new CCEaseBackIn(pAction);
         case CCBKeyframeEasing.BackOut:
             return new CCEaseBackOut(pAction);
         case CCBKeyframeEasing.BackInOut:
             return new CCEaseBackInOut(pAction);
         case CCBKeyframeEasing.BounceIn:
             return new CCEaseBounceIn(pAction);
         case CCBKeyframeEasing.BounceOut:
             return new CCEaseBounceOut(pAction);
         case CCBKeyframeEasing.BounceInOut:
             return new CCEaseBounceInOut(pAction);
         case CCBKeyframeEasing.ElasticIn:
             return new CCEaseElasticIn(pAction, fEasingOpt);
         case CCBKeyframeEasing.ElasticOut:
             return new CCEaseElasticOut(pAction, fEasingOpt);
         case CCBKeyframeEasing.ElasticInOut:
             return new CCEaseElasticInOut(pAction, fEasingOpt);
         default:
             CCLog.Log("CCBReader: Unkown easing type {0}", nEasingType);
             return pAction;
     }
 }
Example #23
0
 public CCSpeed (CCActionInterval action, float fRate)
 {
     InitWithAction(action, fRate);
 }
Example #24
0
 public CCRepeatForever(CCActionInterval action)
 {
     InitWithAction(action);
 }
Example #25
0
 public CCEaseIn (CCActionInterval pAction, float fRate) : base (pAction, fRate)
 { }
Example #26
0
 public CCEaseElasticOut(CCActionInterval pAction, float fPeriod) : base(pAction, fPeriod)
 {
 }
Example #27
0
 public CCEaseInOut(CCActionInterval pAction, float fRate) : base(pAction, fRate)
 {
 }
Example #28
0
        private CCActionInterval GetEaseAction(CCActionInterval pAction, CCBEasingType nEasingTypeType, float fEasingOpt)
        {
            if (pAction is CCSequence)
            {
                return pAction;
            }

            switch (nEasingTypeType)
            {
                case CCBEasingType.Linear:
                    return pAction;
                case CCBEasingType.Instant:
                    return new CCBEaseInstant(pAction);
                case CCBEasingType.CubicIn:
                    return new CCEaseIn(pAction, fEasingOpt);
                case CCBEasingType.CubicOut:
                    return new CCEaseOut(pAction, fEasingOpt);
                case CCBEasingType.CubicInOut:
                    return new CCEaseInOut(pAction, fEasingOpt);
                case CCBEasingType.BackIn:
                    return new CCEaseBackIn(pAction);
                case CCBEasingType.BackOut:
                    return new CCEaseBackOut(pAction);
                case CCBEasingType.BackInOut:
                    return new CCEaseBackInOut(pAction);
                case CCBEasingType.BounceIn:
                    return new CCEaseBounceIn(pAction);
                case CCBEasingType.BounceOut:
                    return new CCEaseBounceOut(pAction);
                case CCBEasingType.BounceInOut:
                    return new CCEaseBounceInOut(pAction);
                case CCBEasingType.ElasticIn:
                    return new CCEaseElasticIn(pAction, fEasingOpt);
                case CCBEasingType.ElasticOut:
                    return new CCEaseElasticOut(pAction, fEasingOpt);
                case CCBEasingType.ElasticInOut:
                    return new CCEaseElasticInOut(pAction, fEasingOpt);
                default:
                    CCLog.Log("CCBReader: Unkown easing type {0}", nEasingTypeType);
                    return pAction;
            }
        }
 public CCEaseElasticInOut(CCActionInterval pAction) : base(pAction, 0.3f)
 {
 }
Example #30
0
 public void InitWithAction(CCActionInterval action, Func <float, float> easeFunc)
 {
     base.InitWithAction(action);
     m_EaseFunc = easeFunc;
 }
 protected CCActionInterval(CCActionInterval actionInterval) : base(actionInterval)
 {
     InitWithDuration(actionInterval.m_fDuration);
 }
 public CCFiniteTimeAction EaseAction(CCActionInterval action)
 {
     return new CCEaseOut(action, 2.0f);
 }
		public CCEaseElasticIn (CCActionInterval pAction, float fPeriod) : base (pAction, fPeriod)
		{ }
 public CCEaseExponentialIn(CCActionInterval pAction) : base(pAction)
 {
 }
        protected CCActionInterval (CCActionInterval actionInterval) : base (actionInterval)
        {
            InitWithDuration(actionInterval.m_fDuration);

        }
 public CCFiniteTimeAction EaseAction(CCActionInterval action)
 {
     return(new CCEaseOut(action, 2.0f));
 }
Example #37
0
 public CCEaseSineIn (CCActionInterval pAction) : base (pAction)
 { }
Example #38
0
 public CCBEaseInstant(CCActionInterval pAction)
 {
     InitWithAction(pAction);
 }
Example #39
0
 public CCEaseElasticOut(CCActionInterval pAction) : base(pAction)
 {
 }
Example #40
0
 public CCBEaseInstant(CCActionInterval pAction)
 {
     InitWithAction(pAction);
 }