예제 #1
0
        public bool InitWithTileFile(string tile, int tileWidth, int tileHeight, int itemsToRender)
        {
            Debug.Assert(tile != null, "title should not be null");

            m_uItemWidth  = tileWidth;
            m_uItemHeight = tileHeight;

            m_cOpacity            = 255;
            m_tColor              = m_tColorUnmodified = CCTypes.CCWhite;
            m_bIsOpacityModifyRGB = true;

            m_tBlendFunc.Source      = CCMacros.CCDefaultSourceBlending;
            m_tBlendFunc.Destination = CCMacros.CCDefaultDestinationBlending;

            var pNewAtlas = new CCTextureAtlas();

            pNewAtlas.InitWithFile(tile, itemsToRender);

            TextureAtlas = pNewAtlas;

            UpdateBlendFunc();
            UpdateOpacityModifyRgb();

            CalculateMaxItems();

            m_uQuadsToDraw = itemsToRender;

            return(true);
        }
예제 #2
0
        public static CCMotionStreak Create(float fade, float minSeg, float stroke, CCColor3B color, string path)
        {
            var pRet = new CCMotionStreak();

            pRet.InitWithFade(fade, minSeg, stroke, color, path);
            return(pRet);
        }
예제 #3
0
        public static CCMenuItem CreateScaledMenuItemLabel(CCSize buttonSize, int labelPadding, float strokeSize, CCColor3B textColor, CCColor3B strokeColor, CCColor3B backColor, string labelText, Action action)
        {
            var menuItem = action != null ? new CCMenuItem(o => action()) : new CCMenuItem();

            var labelSize = new CCSize(buttonSize.Width - labelPadding, buttonSize.Height - labelPadding);

            // Add background
            var blockSprite = new CCSprite("images/Block_Back");
            blockSprite.ScaleTo(buttonSize);
            blockSprite.Color = backColor;

            menuItem.AddChild(blockSprite);
            menuItem.ContentSize = buttonSize;

            // Add label
            var labelTtf = new CCLabelTTF(labelText, "arial-24", 10);
            labelTtf.Color = textColor;

            // Add Stroke to label
            // if (strokeSize > 0) labelTtf.AddStroke(strokeSize, strokeColor);

            if (labelTtf.ContentSize.Width > labelSize.Width)
            {
                labelTtf.ScaleTo(labelSize);
            }

            menuItem.AddChild(labelTtf);

            return menuItem;
        }
        public GameOverLayer(int score, int remoteScore)
        {
            TouchEnabled = true;

            string scoreMessage = String.Format ("Game Over. You collected {0} bananas \r\n Opponent collected {1} bananas!", score, remoteScore);

            var scoreLabel = new CCLabelTTF (scoreMessage, "MarkerFelt", 22) {
                Position = new CCPoint( CCDirector.SharedDirector.WinSize.Center.X,  CCDirector.SharedDirector.WinSize.Center.Y + 50),
                Color = new CCColor3B (XNA.Color.Yellow)
            };

            AddChild (scoreLabel);

            var playAgainLabel = new CCLabelTTF ("Tap to Play Again", "MarkerFelt", 22) {
                Position = CCDirector.SharedDirector.WinSize.Center,
                Color = new CCColor3B (XNA.Color.Green)
            };

            AddChild (playAgainLabel);

            Color = new CCColor3B (XNA.Color.Black);
            Opacity = 255;
            // Clean up the room from the server
            if (Context.isRoomCreator) {
                WarpClient.GetInstance ().DeleteRoom (Context.gameRoomId);
            }
        }
예제 #5
0
        public bool InitWithFade(float fade, float minSeg, float stroke, CCColor3B color, CCTexture2D texture)
        {
            Position    = CCPoint.Zero;
            AnchorPoint = CCPoint.Zero;
            IgnoreAnchorPointForPosition   = true;
            m_bStartingPositionInitialized = false;

            m_tPositionR = CCPoint.Zero;
            m_bFastMode  = true;
            m_fMinSeg    = (minSeg == -1.0f) ? stroke / 5.0f : minSeg;
            m_fMinSeg   *= m_fMinSeg;

            m_fStroke    = stroke;
            m_fFadeDelta = 1.0f / fade;

            m_uMaxPoints     = (int)(fade * 60.0f) + 2;
            m_uNuPoints      = 0;
            m_pPointState    = new float[m_uMaxPoints];
            m_pPointVertexes = new CCPoint[m_uMaxPoints];

            m_pVertices = new CCV3F_C4B_T2F[(m_uMaxPoints + 1) * 2];

            // Set blend mode
            m_tBlendFunc.Source      = OGLES.GL_SRC_ALPHA;
            m_tBlendFunc.Destination = OGLES.GL_ONE_MINUS_SRC_ALPHA;

            // shader program
            // setShaderProgram(CCShaderCache.sharedShaderCache().programForKey(kCCShader_PositionTextureColor));

            Texture = texture;
            Color   = color;
            ScheduleUpdate();

            return(true);
        }
예제 #6
0
        protected virtual bool InitWithFade(float fade, float minSeg, float stroke, CCColor3B color, CCTexture2D texture)
        {
            Position    = CCPoint.Zero;
            AnchorPoint = CCPoint.Zero;
            IgnoreAnchorPointForPosition   = true;
            m_bStartingPositionInitialized = false;

            m_tPositionR = CCPoint.Zero;
            m_bFastMode  = true;
            m_fMinSeg    = (minSeg == -1.0f) ? stroke / 5.0f : minSeg;
            m_fMinSeg   *= m_fMinSeg;

            m_fStroke    = stroke;
            m_fFadeDelta = 1.0f / fade;

            m_uMaxPoints     = (int)(fade * 60.0f) + 2;
            m_uNuPoints      = 0;
            m_pPointState    = new float[m_uMaxPoints];
            m_pPointVertexes = new CCPoint[m_uMaxPoints];

            m_pVertices = new CCV3F_C4B_T2F[(m_uMaxPoints + 1) * 2];

            // Set blend mode
            m_tBlendFunc = CCBlendFunc.NonPremultiplied;

            Texture = texture;
            Color   = color;
            ScheduleUpdate();

            return(true);
        }
        public GameLayer()
        {
            TouchEnabled = true;

            localBananas = new List<CCSprite> ();

            localMonkey = new CCSprite ("MonkeyLocal");

            localMonkey.PositionY = 0;
            localMonkey.PositionX = CCDirector.SharedDirector.WinSize.Width / 2;
            AddChild (localMonkey);

            remoteMonkey = new CCSprite ("MonkeyRemote");
            remoteMonkey.PositionY = CCDirector.SharedDirector.WinSize.Height - remoteMonkey.ContentSizeInPixels.Height/2;
            remoteMonkey.PositionX = CCDirector.SharedDirector.WinSize.Width / 2;
            AddChild (remoteMonkey);

            if (!Context.isRoomCreator) {
                byte[] message = buildStartMessage ();
                sendWarpUpdate (message);
                beginLocalGame ();
            }

            Color = new CCColor3B (XNA.Color.ForestGreen);
            Opacity = 255;
        }
예제 #8
0
        public bool InitWithFade(float fade, float minSeg, float stroke, CCColor3B color, string path)
        {
            Debug.Assert(!String.IsNullOrEmpty(path), "Invalid filename");

            CCTexture2D texture = CCTextureCache.SharedTextureCache.AddImage(path);

            return(InitWithFade(fade, minSeg, stroke, color, texture));
        }
예제 #9
0
 /// <summary>
 /// initializes the transition with a duration and with an RGB color 
 /// </summary>
 protected virtual bool InitWithDuration(float duration, CCScene scene, CCColor3B color)
 {
     if (base.InitWithDuration(duration, scene))
     {
         m_tColor = new CCColor4B {R = color.R, G = color.G, B = color.B, A = 0};
     }
     return true;
 }
예제 #10
0
        //protected bool m_opacityChanged;

        public CCLayerColor()
        {
            m_cOpacity = 0;
            m_tColor   = new CCColor3B(0, 0, 0);

            // default blend function
            m_tBlendFunc = new CCBlendFunc(CCMacros.CCDefaultSourceBlending, CCMacros.CCDefaultDestinationBlending);
            Init();
        }
예제 #11
0
 protected bool InitWithLabel(CCNode label, SEL_MenuHandler selector)
 {
     base.InitWithTarget(selector);
     m_fOriginalScale = 1.0f;
     m_tColorBackup   = CCTypes.CCWhite;
     DisabledColor    = new CCColor3B(126, 126, 126);
     Label            = label;
     return(true);
 }
예제 #12
0
 public CCNodeRGBA()
 {
     _displayedOpacity      = 255;
     _realOpacity           = 255;
     _displayedColor        = CCTypes.CCWhite;
     _realColor             = CCTypes.CCWhite;
     _cascadeColorEnabled   = false;
     _cascadeOpacityEnabled = false;
 }
예제 #13
0
        public void TintWithColor(CCColor3B colors)
        {
            Color = colors;

            for (int i = 0; i < m_uNuPoints * 2; i++)
            {
                m_pVertices[i].Colors = new CCColor4B(colors.R, colors.G, colors.B, 255);
            }
        }
예제 #14
0
 protected bool InitWithLabel(CCNode label, SEL_MenuHandler selector)
 {
     base.InitWithTarget(selector);
     m_fOriginalScale = 1.0f;
     m_tColorBackup = CCTypes.CCWhite;
     DisabledColor = new CCColor3B(126, 126, 126);
     Label = label;
     return true;
 }
예제 #15
0
 /// <summary>
 /// initializes the transition with a duration and with an RGB color
 /// </summary>
 protected virtual bool InitWithDuration(float duration, CCScene scene, CCColor3B color)
 {
     if (base.InitWithDuration(duration, scene))
     {
         m_tColor = new CCColor4B {
             R = color.R, G = color.G, B = color.B, A = 0
         };
     }
     return(true);
 }
예제 #16
0
        //protected bool m_opacityChanged;

        public CCLayerColor()
        {
            m_cOpacity = 0;
            m_tColor = new CCColor3B(0, 0, 0);

            // default blend function
            m_tBlendFunc = new CCBlendFunc(CCMacros.CCDefaultSourceBlending, CCMacros.CCDefaultDestinationBlending);
            Init ();

        }
예제 #17
0
        public override bool Init()
        {
            //base.Init();

            _displayedOpacity      = _realOpacity = 255;
            _displayedColor        = _realColor = CCTypes.CCWhite;
            _cascadeOpacityEnabled = _cascadeColorEnabled = false;

            return(true);
        }
예제 #18
0
        public IntroLayer()
        {
            // setup our color for the background
            Color = new CCColor3B(Microsoft.Xna.Framework.Color.Blue);
            Opacity = 255;

            CameraManager.Instance.Start(this);

            //this.addSprite();
            this.TouchEnabled = true;
            this.ScheduleUpdate();
        }
예제 #19
0
        protected bool InitWithLabel(CCNode label, Action <CCMenuItem> selector)
        {
            base.InitWithTarget(selector);
            m_fOriginalScale = 1.0f;
            m_tColorBackup   = CCTypes.CCWhite;
            DisabledColor    = new CCColor3B(126, 126, 126);
            Label            = label;

            CascadeColorEnabled   = true;
            CascadeOpacityEnabled = true;

            return(true);
        }
예제 #20
0
		protected bool InitWithLabel(CCNode label, Action<object> selector)
        {
            base.InitWithTarget(selector);
            m_fOriginalScale = 1.0f;
            m_tColorBackup = CCTypes.CCWhite;
            DisabledColor = new CCColor3B(126, 126, 126);
            Label = label;

            CascadeColorEnabled = true;
            CascadeOpacityEnabled = true;

            return true;
        }
예제 #21
0
        public virtual void UpdateDisplayedColor(CCColor3B parentColor)
        {
            m_tDisplayedColor.R = (byte)(m_tRealColor.R * parentColor.R / 255.0f);
            m_tDisplayedColor.G = (byte)(m_tRealColor.G * parentColor.G / 255.0f);
            m_tDisplayedColor.B = (byte)(m_tRealColor.B * parentColor.B / 255.0f);

            if (m_pChildren != null)
            {
                for (int i = 0, count = m_pChildren.count; i < count; i++)
                {
                    ((CCSprite)m_pChildren.Elements[i]).UpdateDisplayedColor(m_tDisplayedColor);
                }
            }
        }
예제 #22
0
        public void SetColor(CCColor3B colorValue)
        {
            // XXX fixed me if not correct
            base.Color = colorValue;

            RGBA rgba;
            rgba.r = colorValue.R / 255.0f;
            rgba.g = colorValue.G / 255.0f;
            rgba.b = colorValue.B / 255.0f;
            rgba.a = 1.0f;

            _hsv = CCControlUtils.HSVfromRGB(rgba);
            UpdateHueAndControlPicker();
        }
        public GameStartLayer()
        {
            TouchEnabled = true;

            statusLabel = new CCLabelTTF (status, "MarkerFelt", 22) {
                Position = CCDirector.SharedDirector.WinSize.Center,
                Color = new CCColor3B (XNA.Color.Yellow)
            };

            AddChild(statusLabel);

            Color = new CCColor3B (XNA.Color.ForestGreen);
            Opacity = 255;
        }
예제 #24
0
        public virtual bool onTextFieldInsertText(CCTextFieldTTF pSender, string text, int nLen)
        {
            // if insert enter, treat as default to detach with ime
            if ("\n" == text)
            {
                return(false);
            }

            // if the textfield's char count more than m_nCharLimit, doesn't insert text anymore.
            if (pSender.CharCount >= m_nCharLimit)
            {
                return(true);
            }

            // create a insert text sprite and do some action
            CCLabelTTF label = new CCLabelTTF(text, TextInputTestScene.FONT_NAME, TextInputTestScene.FONT_SIZE);

            this.AddChild(label);
            CCColor3B color = new CCColor3B {
                R = 226, G = 121, B = 7
            };

            label.Color = color;

            // move the sprite from top to position
            CCPoint endPos = pSender.Position;

            if (pSender.CharCount > 0)
            {
                endPos.X += pSender.ContentSize.Width / 2;
            }
            CCSize  inputTextSize = label.ContentSize;
            CCPoint beginPos      = new CCPoint(endPos.X, CCDirector.SharedDirector.WinSize.Height - inputTextSize.Height * 2);

            float duration = 0.5f;

            label.Position = beginPos;
            label.Scale    = 8;

            CCAction seq = CCSequence.FromActions(
                CCSpawn.FromActions(
                    new CCMoveTo(duration, endPos),
                    new CCScaleTo(duration, 1),
                    new CCFadeOut(duration)),
                new CCCallFuncN(callbackRemoveNodeWhenDidAction));

            label.RunAction(seq);
            return(false);
        }
예제 #25
0
        /**
         * Sets the color of the title to use for the specified state.
         *
         * @param color The color of the title to use for the specified state.
         * @param state The state that uses the specified color. The values are described
         * in "CCControlState".
         */

        public virtual void SetTitleColorForState(CCColor3B color, CCControlState state)
        {
            if (m_titleColorDispatchTable.ContainsKey(state))
            {
                m_titleColorDispatchTable.Remove(state);
            }

            m_titleColorDispatchTable.Add(state, color);

            // If the current state if equal to the given state we update the layout
            if (State == state)
            {
                NeedsLayout();
            }
        }
예제 #26
0
        public IntroLayer()
        {
            // create and initialize a Label
            var label = new CCLabelTTF("Hello Cocos2D-XNA", "MarkerFelt", 22);

            // position the label on the center of the screen
            label.Position = CCDirector.SharedDirector.WinSize.Center;

            // add the label as a child to this Layer
            AddChild(label);

            // setup our color for the background
            Color = new CCColor3B(Microsoft.Xna.Framework.Color.Blue);
            Opacity = 255;
        }
        /// <summary>
        /// Initializes the CCLayer with a gradient between start and end in the direction of v.
        /// </summary>
        protected virtual bool InitWithColor(CCColor4B start, CCColor4B end, CCPoint v)
        {
            m_endColor   = new CCColor3B();
            m_endColor.R = end.R;
            m_endColor.G = end.G;
            m_endColor.B = end.B;

            m_cEndOpacity   = end.A;
            m_cStartOpacity = start.A;
            m_AlongVector   = v;

            m_bCompressedInterpolation = true;

            return(base.InitWithColor(new CCColor4B(start.R, start.G, start.B, 255)));
        }
예제 #28
0
 public override void UpdateDisplayedColor(CCColor3B parentColor)
 {
     base.UpdateDisplayedColor(parentColor);
     if (_scale9Image != null && _scale9Image.Children != null && _scale9Image.Children.count != 0)
     {
         for (int i = 0; i < _scale9Image.Children.count; i++)
         {
             var node = _scale9Image.Children[i] as ICCRGBAProtocol;
             if (node != null)
             {
                 node.UpdateDisplayedColor(parentColor);
             }
         }
     }
 }
예제 #29
0
        protected virtual CCColor3B ParsePropTypeColor3(CCNode node, CCNode parent, CCBReader reader, string propertyName)
        {
            byte red   = reader.ReadByte();
            byte green = reader.ReadByte();
            byte blue  = reader.ReadByte();

            var color = new CCColor3B(red, green, blue);

            if (reader.AnimatedProperties.Contains(propertyName))
            {
                CCColor3BWapper value = new CCColor3BWapper(color);
                reader.AnimationManager.SetBaseValue(value, node, propertyName);
            }
            return(color);
        }
        public void SetColor(CCColor3B colorValue)
        {
            // XXX fixed me if not correct
            base.Color = colorValue;

            RGBA rgba;

            rgba.r = colorValue.R / 255.0f;
            rgba.g = colorValue.G / 255.0f;
            rgba.b = colorValue.B / 255.0f;
            rgba.a = 1.0f;

            _hsv = CCControlUtils.HSVfromRGB(rgba);
            UpdateHueAndControlPicker();
        }
예제 #31
0
        public bool InitWithTexture(CCTexture2D pTexture, CCRect rect, bool rotated)
        {
            m_pobBatchNode = null;

            // shader program
            //setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionTextureColor));

            m_bRecursiveDirty = false;
            Dirty             = false;

            m_bOpacityModifyRGB = true;
            m_nOpacity          = 255;
            m_sColor            = m_sColorUnmodified = CCTypes.CCWhite;

            m_sBlendFunc.Source      = CCMacros.CCDefaultSourceBlending;
            m_sBlendFunc.Destination = CCMacros.CCDefaultDestinationBlending;

            m_bFlipX = m_bFlipY = false;

            // default transform anchor: center
            AnchorPoint = new CCPoint(0.5f, 0.5f);

            // zwoptex default values
            m_obOffsetPosition = CCPoint.Zero;

            m_bHasChildren = false;

            // clean the Quad
            m_sQuad = new CCV3F_C4B_T2F_Quad();

            // Atlas: Color
            var tmpColor = new CCColor4B(255, 255, 255, 255);

            m_sQuad.BottomLeft.Colors  = tmpColor;
            m_sQuad.BottomRight.Colors = tmpColor;
            m_sQuad.TopLeft.Colors     = tmpColor;
            m_sQuad.TopRight.Colors    = tmpColor;

            // update texture (calls updateBlendFunc)
            Texture = pTexture;
            SetTextureRect(rect, rotated, rect.Size);

            // by default use "Self Render".
            // if the sprite is added to a batchnode, then it will automatically switch to "batchnode Render"
            BatchNode = null;

            return(true);
        }
예제 #32
0
		public IntroLayer () 
		{

			// create and initialize a Label
			var label = new CCLabelTTF("Intro Layer", "MarkerFelt", 22);

			// position the label on the center of the screen
			label.Position = CCDirector.SharedDirector.WinSize.Center;

			// add the label as a child to this Layer
			AddChild(label);

			// setup our color for the background
			Color = new CCColor3B (Microsoft.Xna.Framework.Color.Blue);
			Opacity = 255;

			// Wait a little and then transition to the new scene
			ScheduleOnce (TransitionOut, 2);
		}
예제 #33
0
        public virtual void UpdateDisplayedColor(CCColor3B parentColor)
        {
            _displayedColor.R = (byte)(_realColor.R * parentColor.R / 255.0f);
            _displayedColor.G = (byte)(_realColor.G * parentColor.G / 255.0f);
            _displayedColor.B = (byte)(_realColor.B * parentColor.B / 255.0f);

            if (_cascadeColorEnabled)
            {
                if (_cascadeOpacityEnabled && m_pChildren != null)
                {
                    for (int i = 0, count = m_pChildren.count; i < count; i++)
                    {
                        var item = m_pChildren.Elements[i] as ICCRGBAProtocol;
                        if (item != null)
                        {
                            item.UpdateDisplayedColor(_displayedColor);
                        }
                    }
                }
            }
        }
예제 #34
0
        public bool InitWithTexture(CCTexture2D texture, int tileWidth, int tileHeight, int itemsToRender)
        {
            m_uItemWidth  = tileWidth;
            m_uItemHeight = tileHeight;

            m_tColorUnmodified    = CCTypes.CCWhite;
            m_bIsOpacityModifyRGB = true;

            m_tBlendFunc = CCBlendFunc.AlphaBlend;

            m_pTextureAtlas = new CCTextureAtlas();
            m_pTextureAtlas.InitWithTexture(texture, itemsToRender);

            UpdateBlendFunc();
            UpdateOpacityModifyRgb();

            CalculateMaxItems();

            m_uQuadsToDraw = itemsToRender;

            return(true);
        }
예제 #35
0
파일: ccTypes.cs 프로젝트: CILP/cocos2d-xna
 //! helper macro that creates an ccColor3B type
 static public CCColor3B CreateColor(byte r, byte g, byte b)
 {
     CCColor3B c = new CCColor3B(r, g, b);
     return c;
 }
예제 #36
0
        public void TintWithColor(CCColor3B colors)
        {
            Color = colors;

            for (int i = 0; i < m_uNuPoints * 2; i++)
            {
                m_pVertices[i].Colors = new CCColor4B(colors.R, colors.G, colors.B, 255);
            }
        }
예제 #37
0
 public static CCMotionStreak Create(float fade, float minSeg, float stroke, CCColor3B color, string path)
 {
     var pRet = new CCMotionStreak();
     pRet.InitWithFade(fade, minSeg, stroke, color, path);
     return pRet;
 }
예제 #38
0
 public CCNodeRGBA()
 {
     _displayedOpacity = 255;
     _realOpacity = 255;
     _displayedColor = CCTypes.CCWhite;
     _realColor = CCTypes.CCWhite;
     _cascadeColorEnabled = false;
     _cascadeOpacityEnabled = false;
 }
예제 #39
0
 public CCColor3BWapper(CCColor3B xcolor)
 {
     color = xcolor;
 }
예제 #40
0
        public virtual void UpdateDisplayedColor(CCColor3B parentColor)
        {
            m_tDisplayedColor.R = (byte) (m_tRealColor.R * parentColor.R / 255.0f);
            m_tDisplayedColor.G = (byte) (m_tRealColor.G * parentColor.G / 255.0f);
            m_tDisplayedColor.B = (byte) (m_tRealColor.B * parentColor.B / 255.0f);

            if (m_pChildren != null)
            {
                for (int i = 0, count = m_pChildren.count; i < count; i++)
                {
                    ((CCSprite) m_pChildren.Elements[i]).UpdateDisplayedColor(m_tDisplayedColor);
                }
            }
        }
예제 #41
0
        public override bool Init()
        {
            //base.Init();

            _displayedOpacity = _realOpacity = 255;
            _displayedColor = _realColor = CCTypes.CCWhite;
            _cascadeOpacityEnabled = _cascadeColorEnabled = false;
            
            return true;
        }
예제 #42
0
 public CCLightningStreak(CCPoint start, CCPoint end, float fadeTime, float minSegLength, float streakWidth, CCColor3B color, string pathToTexture)
     : base(fadeTime, minSegLength, streakWidth, color, pathToTexture)
 {
     _Track = new CCLightningTrack(start, end);
 }
예제 #43
0
        /**
    * Sets the color of the title to use for the specified state.
    *
    * @param color The color of the title to use for the specified state.
    * @param state The state that uses the specified color. The values are described
    * in "CCControlState".
    */

        public virtual void SetTitleColorForState(CCColor3B color, CCControlState state)
        {
            if (m_titleColorDispatchTable.ContainsKey(state))
            {
                m_titleColorDispatchTable.Remove(state);
            }

            m_titleColorDispatchTable.Add(state, color);

            // If the current state if equal to the given state we update the layout
            if (State == state)
            {
                NeedsLayout();
            }
        }
예제 #44
0
        public override void OnEnter()
        {
            base.OnEnter();

            Color = new CCColor3B(0, 0, 0);
            RemoveChild(m_background, true);
            m_background = null;

            m_emitter = new CCParticleSystemQuad();

            string filename = "Particles/" + m_title;
            m_emitter.InitWithFile(filename);
            AddChild(m_emitter, 10);

            m_emitter.BlendAdditive = true;

            setEmitterPosition();
        }
예제 #45
0
        //! helper macro that creates an ccColor3B type
        static public CCColor3B CreateColor(byte r, byte g, byte b)
        {
            CCColor3B c = new CCColor3B(r, g, b);

            return(c);
        }
예제 #46
0
 public CCLightningStreak(CCPoint start, CCPoint end, float sway, float fadeTime, float minSegLength, float streakWidth, CCColor3B color, CCTexture2D texture)
     : base(fadeTime, minSegLength, streakWidth, color, texture)
 {
     _Track      = new CCLightningTrack(start, end);
     _Track.Sway = sway;
 }
예제 #47
0
        public virtual bool InitWithLabelAndBackgroundSprite(CCNode node, CCScale9Sprite backgroundSprite)
        {
            if (base.Init())
            {
                Debug.Assert(node != null, "Label must not be nil.");
                var label     = node as ICCLabelProtocol;
                var rgbaLabel = node as ICCRGBAProtocol;
                Debug.Assert(backgroundSprite != null, "Background sprite must not be nil.");
                Debug.Assert(label != null || rgbaLabel != null || backgroundSprite != null);

                m_bParentInited = true;

                // Initialize the button state tables
                m_titleDispatchTable            = new Dictionary <CCControlState, string>();
                m_titleColorDispatchTable       = new Dictionary <CCControlState, CCColor3B>();
                m_titleLabelDispatchTable       = new Dictionary <CCControlState, CCNode>();
                m_backgroundSpriteDispatchTable = new Dictionary <CCControlState, CCScale9Sprite>();

                TouchEnabled      = true;
                m_isPushed        = false;
                m_zoomOnTouchDown = true;

                m_currentTitle = null;

                // Adjust the background image by default
                SetAdjustBackgroundImage(true);
                PreferredSize = CCSize.Zero;
                // Zooming button by default
                m_zoomOnTouchDown = true;

                // Set the default anchor point
                IgnoreAnchorPointForPosition = false;
                AnchorPoint = new CCPoint(0.5f, 0.5f);

                // Set the nodes
                TitleLabel       = node;
                BackgroundSprite = backgroundSprite;

                // Set the default color and opacity
                Color              = new CCColor3B(255, 255, 255);
                Opacity            = 255;
                IsOpacityModifyRGB = true;

                // Initialize the dispatch table

                string tempString = label.Label;
                //tempString->autorelease();
                SetTitleForState(tempString, CCControlState.Normal);
                SetTitleColorForState(rgbaLabel.Color, CCControlState.Normal);
                SetTitleLabelForState(node, CCControlState.Normal);
                SetBackgroundSpriteForState(backgroundSprite, CCControlState.Normal);

                LabelAnchorPoint = new CCPoint(0.5f, 0.5f);

                NeedsLayout();

                return(true);
            }
            //couldn't init the CCControl
            return(false);
        }
예제 #48
0
        public override void NeedsLayout()
        {
            if (!m_bParentInited)
            {
                return;
            }
            // Hide the background and the label
            if (m_titleLabel != null)
            {
                m_titleLabel.Visible = false;
            }
            if (m_backgroundSprite != null)
            {
                m_backgroundSprite.Visible = false;
            }
            // Update anchor of all labels
            LabelAnchorPoint = m_labelAnchorPoint;

            // Update the label to match with the current state

            m_currentTitle      = GetTitleForState(m_eState);
            m_currentTitleColor = GetTitleColorForState(m_eState);

            TitleLabel = GetTitleLabelForState(m_eState);

            var label = (ICCLabelProtocol)m_titleLabel;

            if (label != null && !String.IsNullOrEmpty(m_currentTitle))
            {
                label.Label = (m_currentTitle);
            }

            var rgbaLabel = (ICCRGBAProtocol)m_titleLabel;

            if (rgbaLabel != null)
            {
                rgbaLabel.Color = m_currentTitleColor;
            }
            if (m_titleLabel != null)
            {
                m_titleLabel.Position = new CCPoint(ContentSize.Width / 2, ContentSize.Height / 2);
            }

            // Update the background sprite
            BackgroundSprite = GetBackgroundSpriteForState(m_eState);
            if (m_backgroundSprite != null)
            {
                m_backgroundSprite.Position = new CCPoint(ContentSize.Width / 2, ContentSize.Height / 2);
            }

            // Get the title label size
            CCSize titleLabelSize = CCSize.Zero;

            if (m_titleLabel != null)
            {
                titleLabelSize = m_titleLabel.BoundingBox.Size;
            }

            // Adjust the background image if necessary
            if (m_doesAdjustBackgroundImage)
            {
                // Add the margins
                if (m_backgroundSprite != null)
                {
                    m_backgroundSprite.ContentSize = new CCSize(titleLabelSize.Width + m_marginH * 2, titleLabelSize.Height + m_marginV * 2);
                }
            }
            else
            {
                //TODO: should this also have margins if one of the preferred sizes is relaxed?
                if (m_backgroundSprite != null)
                {
                    CCSize preferredSize = m_backgroundSprite.PreferredSize;
                    if (preferredSize.Width <= 0)
                    {
                        preferredSize.Width = titleLabelSize.Width;
                    }
                    if (preferredSize.Height <= 0)
                    {
                        preferredSize.Height = titleLabelSize.Height;
                    }

                    m_backgroundSprite.ContentSize = preferredSize;
                }
            }

            // Set the content size
            CCRect rectTitle = CCRect.Zero;

            if (m_titleLabel != null)
            {
                rectTitle = m_titleLabel.BoundingBox;
            }
            CCRect rectBackground = CCRect.Zero;

            if (m_backgroundSprite != null)
            {
                rectBackground = m_backgroundSprite.BoundingBox;
            }

            CCRect maxRect = CCControlUtils.CCRectUnion(rectTitle, rectBackground);

            ContentSize = new CCSize(maxRect.Size.Width, maxRect.Size.Height);

            if (m_titleLabel != null)
            {
                m_titleLabel.Position = new CCPoint(ContentSize.Width / 2, ContentSize.Height / 2);
                // Make visible label
                m_titleLabel.Visible = true;
            }

            if (m_backgroundSprite != null)
            {
                m_backgroundSprite.Position = new CCPoint(ContentSize.Width / 2, ContentSize.Height / 2);
                // Make visible the background
                m_backgroundSprite.Visible = true;
            }
        }
예제 #49
0
파일: ccTypes.cs 프로젝트: CILP/cocos2d-xna
 /** Returns a ccColor4F from a ccColor3B. Alpha will be 1.
  @since v0.99.1
  */
 public static CCColor4F CreateColor(CCColor3B c)
 {
     CCColor4F c4 = new CCColor4F(c.R / 255.0f, c.G / 255.0f, c.B / 255.0f, 1.0f);
     return c4;
 }
예제 #50
0
		void TintMe(CCColor3B theColor)
		{
			
			someSprite.Color = theColor;
			
		}
예제 #51
0
        private CCBKeyframe ReadKeyframe(CCBPropertyType type)
        {
            var keyframe = new CCBKeyframe();

            keyframe.Time = ReadFloat();

            var easingType = (CCBEasingType) ReadInt(false);
            float easingOpt = 0;
            object value = null;

            if (easingType == CCBEasingType.CubicIn
                || easingType == CCBEasingType.CubicOut
                || easingType == CCBEasingType.CubicInOut
                || easingType == CCBEasingType.ElasticIn
                || easingType == CCBEasingType.ElasticOut
                || easingType == CCBEasingType.ElasticInOut)
            {
                easingOpt = ReadFloat();
            }
            keyframe.EasingType = easingType;
            keyframe.EasingOpt = easingOpt;

            if (type == CCBPropertyType.Check)
            {
                value = new CCBValue(ReadBool());
            }
            else if (type == CCBPropertyType.Byte)
            {
                value = new CCBValue(ReadByte());
            }
            else if (type == CCBPropertyType.Color3)
            {
                byte r = ReadByte();
                byte g = ReadByte();
                byte b = ReadByte();

                var c = new CCColor3B(r, g, b);
                value = new CCColor3BWapper(c);
            }
            else if (type == CCBPropertyType.Degrees)
            {
                value = new CCBValue(ReadFloat());
            }
            else if (type == CCBPropertyType.ScaleLock || type == CCBPropertyType.Position || type == CCBPropertyType.FloatXY)
            {
                float a = ReadFloat();
                float b = ReadFloat();

                value = new List<CCBValue>
                    {
                        new CCBValue(a),
                        new CCBValue(b)
                    };
            }
            else if (type == CCBPropertyType.SpriteFrame)
            {
                string spriteSheet = ReadCachedString();
                string spriteFile = ReadCachedString();

                CCSpriteFrame spriteFrame;

                if (String.IsNullOrEmpty(spriteSheet))
                {
                    spriteFile = _CCBRootPath + spriteFile;

                    CCTexture2D texture = CCTextureCache.SharedTextureCache.AddImage(CCFileUtils.RemoveExtension(spriteFile));
                    var bounds = new CCRect(0, 0, texture.ContentSize.Width, texture.ContentSize.Height);
                    spriteFrame = new CCSpriteFrame(texture, bounds);
                }
                else
                {
                    spriteSheet = _CCBRootPath + spriteSheet;
                    CCSpriteFrameCache frameCache = CCSpriteFrameCache.SharedSpriteFrameCache;

                    // Load the sprite sheet only if it is not loaded            
                    if (!_loadedSpriteSheets.Contains(spriteSheet))
                    {
                        frameCache.AddSpriteFramesWithFile(spriteSheet);
                        _loadedSpriteSheets.Add(spriteSheet);
                    }

                    spriteFrame = frameCache.SpriteFrameByName(spriteFile);
                }
                value = spriteFrame;
            }

            keyframe.Value = value;

            return keyframe;
        }
예제 #52
0
 public static CCMotionStreak Create(float fade, float minSeg, float stroke, CCColor3B color, CCTexture2D texture)
 {
     var pRet = new CCMotionStreak();
     pRet.InitWithFade(fade, minSeg, stroke, color, texture);
     return pRet;
 }
예제 #53
0
        protected virtual bool InitWithString(string theString, string fntFile, CCSize dimentions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment,
                                              CCPoint imageOffset, CCTexture2D texture)
        {
            Debug.Assert(m_pConfiguration == null, "re-init is no longer supported");
            Debug.Assert((theString == null && fntFile == null) || (theString != null && fntFile != null),
                         "Invalid params for CCLabelBMFont");

            if (!String.IsNullOrEmpty(fntFile))
            {
                CCBMFontConfiguration newConf = FNTConfigLoadFile(fntFile);
                if (newConf == null)
                {
                    CCLog.Log("CCLabelBMFont: Impossible to create font. Please check file: '{0}'", fntFile);
                    return false;
                }

                m_pConfiguration = newConf;

                m_sFntFile = fntFile;

                if (texture == null)
                {
                    try
                    {
                        texture = CCTextureCache.SharedTextureCache.AddImage(m_pConfiguration.AtlasName);
                    }
                    catch (Exception)
                    {
                        // Try the 'images' ref location just in case.
                        try
                        {
                            texture =
                                CCTextureCache.SharedTextureCache.AddImage(System.IO.Path.Combine("images",
                                                                                                  m_pConfiguration
                                                                                                      .AtlasName));
                        }
                        catch (Exception)
                        {
                            // Lastly, try <font_path>/images/<font_name>
                            string dir = System.IO.Path.GetDirectoryName(m_pConfiguration.AtlasName);
                            string fname = System.IO.Path.GetFileName(m_pConfiguration.AtlasName);
                            string newName = System.IO.Path.Combine(System.IO.Path.Combine(dir, "images"), fname);
                            texture = CCTextureCache.SharedTextureCache.AddImage(newName);
                        }
                    }
                }
            }
            else
            {
                texture = new CCTexture2D();
            }

            if (String.IsNullOrEmpty(theString))
            {
                theString = String.Empty;
            }

            if (base.InitWithTexture(texture, theString.Length))
            {
                m_tDimensions = dimentions;

                m_pHAlignment = hAlignment;
                m_pVAlignment = vAlignment;

                m_cDisplayedOpacity = m_cRealOpacity = 255;
                m_tDisplayedColor = m_tRealColor = CCTypes.CCWhite;
                m_bCascadeOpacityEnabled = true;
                m_bCascadeColorEnabled = true;

                m_obContentSize = CCSize.Zero;

                m_bIsOpacityModifyRGB = m_pobTextureAtlas.Texture.HasPremultipliedAlpha;
                AnchorPoint = new CCPoint(0.5f, 0.5f);

                m_tImageOffset = imageOffset;

                m_pReusedChar = new CCSprite();
                m_pReusedChar.InitWithTexture(m_pobTextureAtlas.Texture, CCRect.Zero, false);
                m_pReusedChar.BatchNode = this;

                SetString(theString, true);

                return true;
            }
            return false;
        }
예제 #54
0
        public bool InitWithFade(float fade, float minSeg, float stroke, CCColor3B color, string path)
        {
            Debug.Assert(!String.IsNullOrEmpty(path), "Invalid filename");

            CCTexture2D texture = CCTextureCache.SharedTextureCache.AddImage(path);
            return InitWithFade(fade, minSeg, stroke, color, texture);
        }
예제 #55
0
        public virtual void UpdateDisplayedColor(CCColor3B parentColor)
        {
            _displayedColor.R = (byte) (_realColor.R * parentColor.R / 255.0f);
            _displayedColor.G = (byte) (_realColor.G * parentColor.G / 255.0f);
            _displayedColor.B = (byte) (_realColor.B * parentColor.B / 255.0f);

            if (_cascadeColorEnabled)
            {
                if (_cascadeOpacityEnabled && m_pChildren != null)
                {
                    for (int i = 0, count = m_pChildren.count; i < count; i++)
                    {
                        var item = m_pChildren.Elements[i] as ICCRGBAProtocol;
                        if (item != null)
                        {
                            item.UpdateDisplayedColor(_displayedColor);
                        }
                    }
                }
            }
        }
예제 #56
0
        public bool InitWithFade(float fade, float minSeg, float stroke, CCColor3B color, CCTexture2D texture)
        {
            Position = CCPoint.Zero;
            AnchorPoint = CCPoint.Zero;
            IgnoreAnchorPointForPosition = true;
            m_bStartingPositionInitialized = false;

            m_tPositionR = CCPoint.Zero;
            m_bFastMode = true;
            m_fMinSeg = (minSeg == -1.0f) ? stroke / 5.0f : minSeg;
            m_fMinSeg *= m_fMinSeg;

            m_fStroke = stroke;
            m_fFadeDelta = 1.0f / fade;

            m_uMaxPoints = (int) (fade * 60.0f) + 2;
            m_uNuPoints = 0;
            m_pPointState = new float[m_uMaxPoints];
            m_pPointVertexes = new CCPoint[m_uMaxPoints];

            m_pVertices = new CCV3F_C4B_T2F[(m_uMaxPoints + 1) * 2];

            // Set blend mode
            m_tBlendFunc.Source = CCOGLES.GL_SRC_ALPHA;
            m_tBlendFunc.Destination = CCOGLES.GL_ONE_MINUS_SRC_ALPHA;

            // shader program
            // setShaderProgram(CCShaderCache.sharedShaderCache().programForKey(kCCShader_PositionTextureColor));

            Texture = texture;
            Color = color;
            ScheduleUpdate();

            return true;
        }
예제 #57
0
        public override void NeedsLayout()
        {
            if (!m_bParentInited)
            {
                return;
            }
            // Hide the background and the label
            if (m_titleLabel != null)
            {
                m_titleLabel.Visible = false;
            }
            if (m_backgroundSprite != null)
            {
                m_backgroundSprite.Visible = false;
            }
            // Update anchor of all labels
            LabelAnchorPoint = m_labelAnchorPoint;

            // Update the label to match with the current state

            m_currentTitle = GetTitleForState(m_eState);
            m_currentTitleColor = GetTitleColorForState(m_eState);

            TitleLabel = GetTitleLabelForState(m_eState);

            var label = (ICCLabelProtocol) m_titleLabel;
            if (label != null && !String.IsNullOrEmpty(m_currentTitle))
            {
                label.Text = (m_currentTitle);
            }

            var rgbaLabel = (ICCRGBAProtocol) m_titleLabel;
            if (rgbaLabel != null)
            {
                rgbaLabel.Color = m_currentTitleColor;
            }
            if (m_titleLabel != null)
            {
                m_titleLabel.Position = new CCPoint(ContentSize.Width / 2, ContentSize.Height / 2);
            }

            // Update the background sprite
            BackgroundSprite = GetBackgroundSpriteForState(m_eState);
            if (m_backgroundSprite != null)
            {
                m_backgroundSprite.Position = new CCPoint(ContentSize.Width / 2, ContentSize.Height / 2);
            }

            // Get the title label size
            CCSize titleLabelSize = CCSize.Zero;
            if (m_titleLabel != null)
            {
                titleLabelSize = m_titleLabel.BoundingBox.Size;
            }

            // Adjust the background image if necessary
            if (m_doesAdjustBackgroundImage)
            {
                // Add the margins
                if (m_backgroundSprite != null)
                {
                    m_backgroundSprite.ContentSize = new CCSize(titleLabelSize.Width + m_marginH * 2, titleLabelSize.Height + m_marginV * 2);
                }
            }
            else
            {
                //TODO: should this also have margins if one of the preferred sizes is relaxed?
                if (m_backgroundSprite != null)
                {
                    CCSize preferredSize = m_backgroundSprite.PreferredSize;
                    if (preferredSize.Width <= 0)
                    {
                        preferredSize.Width = titleLabelSize.Width;
                    }
                    if (preferredSize.Height <= 0)
                    {
                        preferredSize.Height = titleLabelSize.Height;
                    }

                    m_backgroundSprite.ContentSize = preferredSize;
                }
            }

            // Set the content size
            CCRect rectTitle = CCRect.Zero;
            if (m_titleLabel != null)
            {
                rectTitle = m_titleLabel.BoundingBox;
            }
            CCRect rectBackground = CCRect.Zero;
            if (m_backgroundSprite != null)
            {
                rectBackground = m_backgroundSprite.BoundingBox;
            }

            CCRect maxRect = CCControlUtils.CCRectUnion(rectTitle, rectBackground);
            ContentSize = new CCSize(maxRect.Size.Width, maxRect.Size.Height);

            if (m_titleLabel != null)
            {
                m_titleLabel.Position = new CCPoint(ContentSize.Width / 2, ContentSize.Height / 2);
                // Make visible label
                m_titleLabel.Visible = true;
            }

            if (m_backgroundSprite != null)
            {
                m_backgroundSprite.Position = new CCPoint(ContentSize.Width / 2, ContentSize.Height / 2);
                // Make visible the background
                m_backgroundSprite.Visible = true;
            }
        }
예제 #58
0
        private CCActionInterval GetAction(CCBKeyframe pKeyframe0, CCBKeyframe pKeyframe1, string pPropName, CCNode node)
        {
            float duration = pKeyframe1.Time - (pKeyframe0 != null ? pKeyframe0.Time : 0);

            switch (pPropName)
            {
            case "rotation":
            {
                var value = (CCBValue)pKeyframe1.Value;
                return(new CCBRotateTo(duration, value.GetFloatValue()));
            }

            case "opacity":
            {
                var value = (CCBValue)pKeyframe1.Value;
                return(new CCFadeTo(duration, value.GetByteValue()));
            }

            case "color":
            {
                var       color = (CCColor3BWapper)pKeyframe1.Value;
                CCColor3B c     = color.getColor();

                return(new CCTintTo(duration, c.R, c.G, c.B));
            }

            case "visible":
            {
                var value = (CCBValue)pKeyframe1.Value;
                if (value.GetBoolValue())
                {
                    return(new CCSequence(new CCDelayTime(duration), new CCShow()));
                }
                return(new CCSequence(new CCDelayTime(duration), new CCHide()));
            }

            case "displayFrame":
                return(new CCSequence(new CCDelayTime(duration), new CCBSetSpriteFrame((CCSpriteFrame)pKeyframe1.Value)));

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

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

                CCSize containerSize = GetContainerSize(node.Parent);

                CCPoint absPos = CCBHelper.GetAbsolutePosition(new CCPoint(x, y), type, containerSize, pPropName);

                return(new CCMoveTo(duration, absPos));
            }

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

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

                if (type == CCBScaleType.MultiplyResolution)
                {
                    float resolutionScale = CCBReader.ResolutionScale;
                    x *= resolutionScale;
                    y *= resolutionScale;
                }

                return(new CCScaleTo(duration, x, y));
            }

            default:
                CCLog.Log("CCBReader: Failed to create animation for property: {0}", pPropName);
                break;
            }

            return(null);
        }
예제 #59
0
        /** Returns a ccColor4F from a ccColor3B. Alpha will be 1.
         * @since v0.99.1
         */
        public static CCColor4F CreateColor(CCColor3B c)
        {
            CCColor4F c4 = new CCColor4F(c.R / 255.0f, c.G / 255.0f, c.B / 255.0f, 1.0f);

            return(c4);
        }
예제 #60
0
        public virtual bool InitWithLabelAndBackgroundSprite(CCNode node, CCScale9Sprite backgroundSprite)
        {
            if (base.Init())
            {
                Debug.Assert(node != null, "Label must not be nil.");
                var label = node as ICCLabelProtocol;
                var rgbaLabel = node as ICCRGBAProtocol;
                Debug.Assert(backgroundSprite != null, "Background sprite must not be nil.");
                Debug.Assert(label != null || rgbaLabel != null || backgroundSprite != null);

                m_bParentInited = true;

                // Initialize the button state tables
                m_titleDispatchTable = new Dictionary<CCControlState, string>();
                m_titleColorDispatchTable = new Dictionary<CCControlState, CCColor3B>();
                m_titleLabelDispatchTable = new Dictionary<CCControlState, CCNode>();
                m_backgroundSpriteDispatchTable = new Dictionary<CCControlState, CCScale9Sprite>();

                TouchEnabled = true;
                m_isPushed = false;
                m_zoomOnTouchDown = true;

                m_currentTitle = null;

                // Adjust the background image by default
                SetAdjustBackgroundImage(true);
                PreferredSize = CCSize.Zero;
                // Zooming button by default
                m_zoomOnTouchDown = true;

                // Set the default anchor point
                IgnoreAnchorPointForPosition = false;
                AnchorPoint = new CCPoint(0.5f, 0.5f);

                // Set the nodes
                TitleLabel = node;
                BackgroundSprite = backgroundSprite;

                // Set the default color and opacity
                Color = new CCColor3B(255, 255, 255);
                Opacity = 255;
                IsOpacityModifyRGB = true;

                // Initialize the dispatch table

                string tempString = label.Text;
                //tempString->autorelease();
                SetTitleForState(tempString, CCControlState.Normal);
                SetTitleColorForState(rgbaLabel.Color, CCControlState.Normal);
                SetTitleLabelForState(node, CCControlState.Normal);
                SetBackgroundSpriteForState(backgroundSprite, CCControlState.Normal);

                LabelAnchorPoint = new CCPoint(0.5f, 0.5f);

                NeedsLayout();

                return true;
            }
            //couldn't init the CCControl
            return false;
        }