/** Hackish stuff - stole touches from other CCTouchDispatcher targeted delegates.
         * Used to claim touch without receiving ccTouchBegan. */
        void claimTouch(UITouch aTouch)
        {
            CCTouchDispatcher dispatcher = CCDirector.sharedDirector.touchDispatcher;

            // Enumerate through all targeted handlers.

            var enumerator = dispatcher.getTargetedHandlers().GetEnumerator();

            while (enumerator.MoveNext())
            {
                CCTargetedTouchHandler handler = (CCTargetedTouchHandler)enumerator.Current;
                // Only our handler should claim the touch.
                if (handler.delegate_ == this)
                {
                    if (!(handler.claimedTouches.Contains(aTouch)))
                    {
                        handler.claimedTouches.Add(aTouch);
                    }
                }
                else
                {
                    // Steal touch from other targeted delegates, if they claimed it.
                    if (handler.claimedTouches.Contains(aTouch))
                    {
                        CCTouchOneByOneDelegate oneByOneTouchDelegate = (CCTouchOneByOneDelegate)handler.delegate_;
                        if (oneByOneTouchDelegate != null)
                        {
                            oneByOneTouchDelegate.ccTouchCancelled(aTouch);
                        }
                        handler.claimedTouches.Remove(aTouch);
                    }
                }
            }
        }
        /** Register with more priority than CCMenu's but don't swallow touches. */
        protected override void registerWithTouchDispatcher()
        {
            CCTouchDispatcher dispatcher = CCDirector.sharedDirector.touchDispatcher;
            int priority = _touchPriority;

            dispatcher.addTargetedDelegate(this, priority, false);
        }
예제 #3
0
        protected CCDirector()
        {
            CCDebug.Log("cocos2d: cocos2d-iphone v2.1");
            // scenes
            _runningScene = null;
            _nextScene    = null;

//			_notificationNode = nil;

            _oldAnimationInterval = _animationInterval = 1.0f / kDefaultFPS;
            _scenesStack          = new Stack <CCScene> (10);

            // Set default projection (3D)
//			_projection = kCCDirectorProjectionDefault;

            // projection delegate if "Custom" projection is used
//			_delegate = nil;

            // FPS
            _displayStats = false;

            _displayError = false;

//			_totalFrames = _frames = 0;

            // paused ?
            _isPaused = false;

            // running thread
//			_runningThread = null;

            // scheduler
            _scheduler = new CCScheduler();

            // action manager
            _actionManager = new CCActionManager();
            _scheduler.scheduleUpdate(_actionManager, CCScheduler.kCCPrioritySystem, false);

            _winSizeInPixels = Vector2.zero;


            //CCDirectorIOS
//			_ccContentScaleFactor = 1;
//			_isContentScaleSupported = false;
            _touchDispatcher = new CCTouchDispatcher();
        }
예제 #4
0
        /** set event handler priority. By default it is: kCCMenuTouchPriority */
        public void setHandlerPriority(int newPriority)
        {
            CCTouchDispatcher dispatcher = CCDirector.sharedDirector.touchDispatcher;

            dispatcher.setPriority(newPriority, this);
        }