Example #1
0
        public void OnCocos2dEvent(Cocos2dEvent theEvent)
        {
            Dispatcher.BeginInvoke(() =>
            {
                switch (theEvent)
                {
                case Cocos2dEvent.ShowKeyboard:
                    if (m_textBox == null)
                    {
                        m_textBox           = new TextBox();
                        m_textBox.Opacity   = 0.0;
                        m_textBox.Width     = 1;
                        m_textBox.Height    = 1;
                        m_textBox.MaxLength = 1;
                        m_textBox.KeyDown  += OnKeyDown;
                        m_textBox.KeyUp    += OnKeyUp;
                        LayoutRoot.Children.Add(m_textBox);
                    }
                    m_textBox.Focus();
                    break;

                case Cocos2dEvent.HideKeyboard:
                    if (m_textBox != null)
                    {
                        LayoutRoot.Children.Remove(m_textBox);
                    }
                    m_textBox = null;
                    break;
                }
            });
        }
        // events called by the Cocos2d-x C++ engine to be handled by C#
        public void OnCocos2dEvent(Cocos2dEvent theEvent)
        {
            Dispatcher.BeginInvoke(() =>
            {
                switch (theEvent)
                {
                case Cocos2dEvent.TerminateApp:
                    Application.Current.Terminate();
                    break;

                case Cocos2dEvent.ShowKeyboard:
                    if (m_textBox == null)
                    {
                        m_textBox           = new TextBox();
                        m_textBox.Opacity   = 0.0;
                        m_textBox.Width     = 1;
                        m_textBox.Height    = 1;
                        m_textBox.MaxLength = 1;
                        m_textBox.KeyDown  += OnKeyDown;
                        m_textBox.KeyUp    += OnKeyUp;
                        DrawingSurfaceBackground.Children.Add(m_textBox);
                    }
                    m_textBox.Focus();
                    break;

                case Cocos2dEvent.HideKeyboard:
                    if (m_textBox != null)
                    {
                        DrawingSurfaceBackground.Children.Remove(m_textBox);
                    }
                    m_textBox = null;
                    break;
                }
            });
        }
Example #3
0
        public void OnCocos2dEvent(Cocos2dEvent theEvent)
        {
            Dispatcher.BeginInvoke(() =>
            {
                switch (theEvent)
                {
                    case Cocos2dEvent.ShowKeyboard:
                        if (m_textBox == null)
                        {
                            m_textBox = new TextBox();
                            m_textBox.Opacity = 0.0;
                            m_textBox.Width = 1;
                            m_textBox.Height = 1;
                            m_textBox.MaxLength = 1;
                            m_textBox.KeyDown += OnKeyDown;
                            m_textBox.KeyUp += OnKeyUp;
                            LayoutRoot.Children.Add(m_textBox);
                        }
                        m_textBox.Focus();
                        break;

                    case Cocos2dEvent.HideKeyboard:
                        if (m_textBox != null)
                        {
                            LayoutRoot.Children.Remove(m_textBox);
                        }
                        m_textBox = null;
                        break;
                }
            });
        }
Example #4
0
        // events called by the Cocos2d-x C++ engine to be handled by C#
        public void OnCocos2dEvent(Cocos2dEvent theEvent, String text)
        {
            Dispatcher.BeginInvoke(() =>
            {
                switch (theEvent)
                {
                    case Cocos2dEvent.TerminateApp:
                        Application.Current.Terminate();
                        break;

                    case Cocos2dEvent.ShowKeyboard:
                        if (m_textBox == null)
                        {
                            m_textBox = new TextBox();
                            m_textBox.Opacity = 0.0;
                            m_textBox.Width = 1;
                            m_textBox.Height = 1;
                            m_textBox.KeyDown += OnKeyDown;
                            m_textBox.TextChanged += OnTextChanged;
                            DrawingSurfaceBackground.Children.Add(m_textBox);
                        }
                        m_textBox.Text = text;
                        m_textBox.SelectionLength = 0;
                        m_textBox.SelectionStart = int.MaxValue;
                        m_textBox.Focus();
                        break;

                    case Cocos2dEvent.HideKeyboard:
                        if (m_textBox != null)
                        {
                            DrawingSurfaceBackground.Children.Remove(m_textBox);
                        }
                        m_textBox = null;
                        break;
                }
            });
        }
Example #5
0
        // events called by the Cocos2d-x C++ engine to be handled by C#
        public void OnCocos2dEvent(Cocos2dEvent theEvent)
        {
            Dispatcher.BeginInvoke(() =>
            {
                switch (theEvent)
                {
                    case Cocos2dEvent.TerminateApp:
                        Application.Current.Terminate();
                        break;

                    case Cocos2dEvent.ShowKeyboard:
                        if (m_textBox == null)
                        {
                            m_textBox = new TextBox();
                            m_textBox.Opacity = 0.0;
                            m_textBox.Width = 1;
                            m_textBox.Height = 1;
                            m_textBox.MaxLength = 1;
                            m_textBox.KeyDown += OnKeyDown;
                            m_textBox.KeyUp += OnKeyUp;
                            DrawingSurfaceBackground.Children.Add(m_textBox);
                        }
                        m_textBox.Focus();
                        break;

                    case Cocos2dEvent.HideKeyboard:
                        if (m_textBox != null)
                        {
                            DrawingSurfaceBackground.Children.Remove(m_textBox);
                        }
                        m_textBox = null;
                        break;
                    case Cocos2dEvent.GiveScore:
                        GiveScore();
                        break;
                }
            });
        }