Пример #1
0
        public CCLayer(CCClipMode clipMode)
        {
            m_childClippingMode             = clipMode;
            AnchorPoint                     = new CCPoint(0.5f, 0.5f);
            m_bIgnoreAnchorPointForPosition = true;
            CCDirector director = CCDirector.SharedDirector;

            if (director != null)
            {
                ContentSize = director.WinSize;
            }
            Init();
        }
Пример #2
0
        private void BeforeDraw()
        {
            CCDirector director = CCDirector.SharedDirector;
            // TODO: Add the RenderTarget support here
            CCPoint screenPos = Parent.ConvertToWorldSpace(Position);

            if (screenPos.X < 0f || screenPos.X > director.WinSize.Width || screenPos.Y < 0f || screenPos.Y > director.WinSize.Height)
            {
                // ScissorRect can not be applied outside of the viewport.
                return;
            }
            float s = Scale;

            s *= director.ContentScaleFactor;

            CCSize winSize = CCDirector.SharedDirector.WinSize;

            CCRect m_tViewSize = BoundingBox; // We always clip to the bounding box
            float  x           = screenPos.X;
            float  y           = winSize.Height - (screenPos.Y + m_tViewSize.Size.Height * s);
            float  scissorW    = m_tViewSize.Size.Width * s;
            float  scissorH    = m_tViewSize.Size.Height * s;

            if (x < 0)
            {
                x = 0f;
            }
            if (y < 0)
            {
                y = 0f;
            }
            if (x + scissorW > winSize.Width)
            {
                scissorW = winSize.Width - x;
            }
            if (y + scissorH > winSize.Height)
            {
                scissorH = winSize.Height - y;
            }
            if (scissorW < 0f || scissorH < 0f)
            {
                return;
            }
            if (x < 0 || y < 0 || (x + scissorW) > winSize.Width || (y + scissorH) > winSize.Height)
            {
            }
            CCDrawManager.ScissorRectEnabled = true;
            CCDrawManager.SetScissorInPoints(x, y, scissorW, scissorH);
        }
Пример #3
0
        public CCNode()
        {
            m_fScaleX  = 1.0f;
            m_fScaleY  = 1.0f;
            m_bVisible = true;
            m_nTag     = kCCNodeTagInvalid;

            m_sTransform    = CCAffineTransform.Identity;
            m_bInverseDirty = true;

            // set default scheduler and actionManager
            CCDirector director = CCDirector.SharedDirector;

            m_pActionManager = director.ActionManager;
            m_pScheduler     = director.Scheduler;
        }
Пример #4
0
        //private bool m_bMouseEnabled;
        //private bool m_bGamePadEnabled;

        public CCLayer()
        {
            AnchorPoint = new CCPoint(0.5f, 0.5f);
            m_bIgnoreAnchorPointForPosition = true;
            CCDirector director = CCDirector.SharedDirector;

            if (director != null)
            {
                ContentSize = director.WinSize;
            }
            m_OnGamePadButtonUpdateDelegate     = new CCGamePadButtonDelegate(OnGamePadButtonUpdate);
            m_OnGamePadConnectionUpdateDelegate = new CCGamePadConnectionDelegate(OnGamePadConnectionUpdate);
            m_OnGamePadDPadUpdateDelegate       = new CCGamePadDPadDelegate(OnGamePadDPadUpdate);
            m_OnGamePadStickUpdateDelegate      = new CCGamePadStickUpdateDelegate(OnGamePadStickUpdate);
            m_OnGamePadTriggerUpdateDelegate    = new CCGamePadTriggerDelegate(OnGamePadTriggerUpdate);
            Init();
        }
Пример #5
0
        private void SetNewScene(float dt)
        {
            // [self unschedule:_cmd];
            // "_cmd" is a local variable automatically defined in a method
            // that contains the selector for the method
            Unschedule(SetNewScene);
            CCDirector director = CCDirector.SharedDirector;

            // Before replacing, save the "send cleanup to scene"
            m_bIsSendCleanupToScene = director.IsSendCleanupToScene();
            director.ReplaceScene(m_pInScene);
            // enable events while transitions
            director.TouchDispatcher.IsDispatchEvents = true;

            // issue #267
            m_pOutScene.Visible = true;
        }
Пример #6
0
        /**
         * clip this view so that outside of the visible bounds can be hidden.
         */

        private void BeforeDraw()
        {
            if (m_bClippingToBounds)
            {
                CCPoint screenPos = Parent.ConvertToWorldSpace(Position);

                float s = Scale;

                CCDirector director = CCDirector.SharedDirector;
                s *= director.ContentScaleFactor;

                CCSize winSize = CCDirector.SharedDirector.WinSize;

                CCDrawManager.ScissorRectEnabled = true;
                CCDrawManager.SetScissorInPoints(screenPos.X, winSize.Height - (screenPos.Y + m_tViewSize.Height * s), m_tViewSize.Width * s,
                                                 m_tViewSize.Height * s);
            }
        }
Пример #7
0
        public override void OnEnter()
        {
            if (!m_bDidInit)
            {
                Init();
            }
            // register 'parent' nodes first
            // since events are propagated in reverse order
            if (m_bIsMultiTouchEnabled || m_bIsSingleTouchEnabled)
            {
                RegisterWithTouchDispatcher();
            }

            // then iterate over all the children
            base.OnEnter();

            CCDirector    director    = CCDirector.SharedDirector;
            CCApplication application = CCApplication.SharedApplication;

            // add this layer to concern the Accelerometer Sensor
            if (m_bIsAccelerometerEnabled)
            {
#if !PSM && !NETFX_CORE
                director.Accelerometer.SetDelegate(this);
#endif
            }
            // add this layer to concern the kaypad msg
            if (m_bKeypadEnabled)
            {
                director.KeypadDispatcher.AddDelegate(this);
            }

            if (GamePadEnabled && director.GamePadEnabled)
            {
                application.GamePadButtonUpdate     += m_OnGamePadButtonUpdateDelegate;
                application.GamePadConnectionUpdate += m_OnGamePadConnectionUpdateDelegate;
                application.GamePadDPadUpdate       += m_OnGamePadDPadUpdateDelegate;
                application.GamePadStickUpdate      += m_OnGamePadStickUpdateDelegate;
                application.GamePadTriggerUpdate    += m_OnGamePadTriggerUpdateDelegate;
            }
        }
Пример #8
0
        public override void OnEnter()
        {
            if (!m_bDidInit)
            {
                Init();
            }

            // then iterate over all the children
            base.OnEnter();

            CCDirector    director    = CCDirector.SharedDirector;
            CCApplication application = CCApplication.SharedApplication;

            // add this layer to concern the Accelerometer Sensor
            if (m_bIsAccelerometerEnabled)
            {
#if !PSM && !NETFX_CORE
                director.Accelerometer.SetDelegate(this);
#endif
            }
        }
Пример #9
0
        public override bool Init()
        {
            if (m_bDidInit)
            {
                return(true);
            }

            TouchMode = CCTouchMode.AllAtOnce;

            bool       bRet     = false;
            CCDirector director = CCDirector.SharedDirector;

            if (director != null)
            {
                //                ContentSize = director.WinSize;
                m_bIsAccelerometerEnabled = false;
                bRet       = true;
                m_bDidInit = true;
            }
            return(bRet);
        }
Пример #10
0
        public override bool Init()
        {
            if (m_bDidInit)
            {
                return(true);
            }
            bool       bRet     = false;
            CCDirector director = CCDirector.SharedDirector;

            if (director != null)
            {
                //                ContentSize = director.WinSize;
                m_bTouchEnabled           = false;
                m_bIsAccelerometerEnabled = false;
                m_bKeypadEnabled          = false;
                m_bGamePadEnabled         = false;
                bRet       = true;
                m_bDidInit = true;
            }
            return(bRet);
        }
Пример #11
0
        public override void RegisterWithTouchDispatcher()
        {
            CCDirector pDirector = CCDirector.SharedDirector;

            pDirector.TouchDispatcher.AddTargetedDelegate(this, kCCMenuHandlerPriority, true);
        }