Esempio n. 1
0
 public static CCScale9Sprite CreateWithSpriteFrameName(string spriteFrameName)
 {
     var pReturn = new CCScale9Sprite();
     pReturn.InitWithSpriteFrameName(spriteFrameName);
     return pReturn;
 }
Esempio n. 2
0
 public CCScale9Sprite ResizableSpriteWithCapInsets(CCRect capInsets)
 {
     var pReturn = new CCScale9Sprite();
     pReturn.InitWithBatchNode(scale9Image, m_spriteRect, capInsets);
     return pReturn;
 }
Esempio n. 3
0
 public static new CCScale9Sprite Create()
 {
     var pReturn = new CCScale9Sprite();
     return pReturn;
 }
Esempio n. 4
0
 public static CCScale9Sprite CreateWithSpriteFrameName(string spriteFrameName, CCRect capInsets)
 {
     var pReturn = new CCScale9Sprite();
     pReturn.InitWithSpriteFrameName(spriteFrameName, capInsets);
     return pReturn;
 }
Esempio n. 5
0
 public static CCScale9Sprite Create(CCRect capInsets, string file)
 {
     var pReturn = new CCScale9Sprite();
     pReturn.InitWithFile(file, capInsets);
     return pReturn;
 }
Esempio n. 6
0
 public static CCScale9Sprite Create(string file)
 {
     var pReturn = new CCScale9Sprite();
     pReturn.InitWithFile(file);
     return pReturn;
 }
Esempio n. 7
0
        /**
        * Sets the background sprite to use for the specified button state.
        *
        * @param sprite The background sprite to use for the specified state.
        * @param state The state that uses the specified image. The values are described
        * in "CCControlState".
        */
        public virtual void SetBackgroundSpriteForState(CCScale9Sprite sprite, CCControlState state)
        {
            CCSize oldPreferredSize = m_preferredSize;

            CCScale9Sprite previousBackgroundSprite;
            if (m_backgroundSpriteDispatchTable.TryGetValue(state, out previousBackgroundSprite))
            {
                RemoveChild(previousBackgroundSprite, true);
                m_backgroundSpriteDispatchTable.Remove(state);
            }

            m_backgroundSpriteDispatchTable.Add(state, sprite);
            sprite.Visible = false;
            sprite.AnchorPoint = new CCPoint(0.5f, 0.5f);
            AddChild(sprite);

            if (m_preferredSize.Width != 0 || m_preferredSize.Height != 0)
            {
                if (oldPreferredSize.Equals(m_preferredSize))
                {
                    // Force update of preferred size
                    sprite.PreferredSize = new CCSize(oldPreferredSize.Width + 1, oldPreferredSize.Height + 1);
                }

                sprite.PreferredSize = m_preferredSize;
            }

            // If the current state if equal to the given state we update the layout
            if (State == state)
            {
                NeedsLayout();
            }
        }
Esempio n. 8
0
 protected virtual bool InitWithBackgroundSprite(CCScale9Sprite sprite)
 {
     CCLabelTTF label = new CCLabelTTF("", "arial", 30);
     return InitWithLabelAndBackgroundSprite(label, sprite);
 }
Esempio n. 9
0
 public CCControlButton(CCScale9Sprite sprite)
 {
     InitWithBackgroundSprite(sprite);
 }
Esempio n. 10
0
 public CCControlButton(CCNode label, CCScale9Sprite backgroundSprite)
 {
     InitWithLabelAndBackgroundSprite(label, backgroundSprite);
 }
Esempio n. 11
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;
        }
Esempio n. 12
0
 public static CCControlButton Create(CCScale9Sprite sprite)
 {
     var pRet = new CCControlButton();
     pRet.InitWithBackgroundSprite(sprite);
     return pRet;
 }
Esempio n. 13
0
 public static CCControlButton Create(CCNode label, CCScale9Sprite backgroundSprite)
 {
     var pRet = new CCControlButton();
     pRet.InitWithLabelAndBackgroundSprite(label, backgroundSprite);
     return pRet;
 }