コード例 #1
0
ファイル: CCTMXLayer.cs プロジェクト: chengcong/cocos2d-xna
 public void removeTileAt(CCPoint pos)
 {
     if (this.tileGIDAt(pos) != 0)
     {
         int num  = (int)(pos.x + pos.y * this.m_tLayerSize.width);
         int num1 = this.atlasIndexForExistantZ(num);
         this.m_pTiles[num] = 0;
         ccCArray.ccCArrayRemoveValueAtIndex(this.m_pAtlasIndexArray, num1);
         CCSprite childByTag = (CCSprite)base.getChildByTag(num);
         if (childByTag != null)
         {
             base.removeChild(childByTag, true);
             return;
         }
         this.m_pobTextureAtlas.removeQuadAtIndex(num1);
         if (this.m_pChildren != null && this.m_pChildren.Count > 0)
         {
             CCObject cCObject = null;
             for (int i = 0; i < this.m_pChildren.Count; i++)
             {
                 CCSprite cCSprite = (CCSprite)cCObject;
                 if (cCSprite != null)
                 {
                     int num2 = cCSprite.atlasIndex;
                     if (num2 >= num1)
                     {
                         cCSprite.atlasIndex = num2 - 1;
                     }
                 }
             }
         }
     }
 }
コード例 #2
0
 public void setObject(CCObject pObj)
 {
     if (pObj != m_pObject)
     {
         m_pObject = pObj;
     }
 }
コード例 #3
0
 public void backCallback(CCObject pSender)
 {
     CCScene s = new ProgressActionsTestScene();
     s.addChild(ProgressActionsTestScene.backAction());
     CCDirector.sharedDirector().replaceScene(s);
     //s->release();
 }
コード例 #4
0
        /// <summary>
        /// Removes all actions from a certain target.
        /// All the actions that belongs to the target will be removed.
        /// </summary>
        public void removeAllActionsFromTarget(CCObject target)
        {
            if (target == null)
            {
                return;
            }

            if (m_pTargets.ContainsKey(target))
            {
                tHashElement element = m_pTargets[target];

                if (element.actions.Contains(element.currentAction) && (!element.currentActionSalvaged))
                {
                    element.currentActionSalvaged = true;
                }

                element.actions.Clear();
                if (m_pCurrentTarget == element)
                {
                    m_bCurrentTargetSalvaged = true;
                }
                else
                {
                    deleteHashElement(element);
                }
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("cocos2d: removeAllActionsFromTarget: Target not found");
            }
        }
コード例 #5
0
ファイル: CCCallFuncO.cs プロジェクト: chengcong/cocos2d-xna
 public void setObject(CCObject pObj)
 {
     if (pObj != this.m_pObject)
     {
         this.m_pObject = pObj;
     }
 }
コード例 #6
0
        public void menuCallback(CCObject pSender)
        {
            CCMenuItemFont pItem = (CCMenuItemFont)pSender;
            int nIndex = pItem.zOrder - BugsTestScene.kItemTagBasic;

            CCScene pScene = CCScene.node();
            CCLayer pLayer = null;

            switch (nIndex)
            {
                case 0:
                    pLayer = new Bug350Layer();
                    pLayer.init();
                    break;
                case 1:
                    pLayer = new Bug422Layer();
                    pLayer.init();
                    break;
                case 2:
                    pLayer = new Bug458Layer();
                    pLayer.init();
                    break;
                case 3:
                    pLayer = new Bug624Layer();
                    pLayer.init();
                    break;
                case 4:
                    pLayer = new Bug886Layer();
                    pLayer.init();
                    break;
                case 5:
                    pLayer = new Bug899Layer();
                    pLayer.init();
                    break;
                case 6:
                    pLayer = new Bug914Layer();
                    pLayer.init();
                    break;
                case 7:
                    pLayer = new Bug1159Layer();
                    pLayer.init();
                    break;
                case 8:
                    pLayer = new Bug1174Layer();
                    pLayer.init();
                    break;
                case 9:
                    pLayer = new CCDefaultCodeBug();
                    pLayer.init();
                    break;
                case 10:
                    pLayer = new DispatcherTest();
                    pLayer.init();
                    break;
                default:
                    break;
            }
            pScene.addChild(pLayer);
            CCDirector.sharedDirector().replaceScene(pScene);
        }
コード例 #7
0
 public void backCallback(CCObject pSender)
 {
     CCScene s = new TextInputTestScene();
     s.addChild(textinputTestScene.backTextInputTest());
     CCDirector.sharedDirector().replaceScene(s);
     //s->release();
 }
コード例 #8
0
        public void restartCallback(CCObject pSender)
        {
            CCScene s = new ActionManagerTestScene();
            s.addChild(restartActionManagerAction());

            CCDirector.sharedDirector().replaceScene(s);
        }
コード例 #9
0
        public void restartCallback(CCObject pSender)
        {
            CCScene s = new ParallaxTestScene();
            s.addChild(ParallaxTestScene.restartParallaxAction());

            CCDirector.sharedDirector().replaceScene(s);
        }
コード例 #10
0
 public void onReplaceScene(CCObject pSender)
 {
     CCScene pScene = new SceneTestScene();
     CCLayer pLayer = new SceneTestLayer3();
     pScene.addChild(pLayer, 0);
     CCDirector.sharedDirector().replaceScene(pScene);
 }
コード例 #11
0
        public virtual void nextCallback(CCObject pSender)
        {
            m_nCurCase++;
            m_nCurCase = m_nCurCase % m_nMaxCases;

            showCurrentTest();
        }
コード例 #12
0
 /// <summary>
 /// Pauses the target: all running actions and newly added actions will be paused.
 /// </summary>
 public void pauseTarget(CCObject target)
 {
     if (m_pTargets.ContainsKey(target))
     {
         m_pTargets[target].paused = true;
     }
 }
コード例 #13
0
 public void onPause(CCObject pSender)
 {
     if (CCDirector.sharedDirector().isPaused)
         CCDirector.sharedDirector().resume();
     else
         CCDirector.sharedDirector().pause();
 }
コード例 #14
0
        public void restartCallback(CCObject pSender)
        {
            CCScene s = new CocosNodeTestScene();//CCScene.node();
            s.addChild(CocosNodeTestScene.restartCocosNodeAction());

            CCDirector.sharedDirector().replaceScene(s);
        }
コード例 #15
0
        public void removeSpriteFromAtlas(CCSprite pobSprite)
        {
            this.m_pobTextureAtlas.removeQuadAtIndex(pobSprite.atlasIndex);
            pobSprite.useSelfRender();
            uint index = (uint)this.m_pobDescendants.IndexOf(pobSprite);

            if (index != uint.MaxValue)
            {
                this.m_pobDescendants.RemoveAt((int)index);
                int count = this.m_pobDescendants.Count;
                while (index < count)
                {
                    CCSprite sprite = this.m_pobDescendants[(int)index];
                    sprite.atlasIndex--;
                    index++;
                }
            }
            List <CCNode> children = pobSprite.children;

            if ((children != null) && (children.Count > 0))
            {
                CCObject obj2 = null;
                for (int i = 0; i < children.Count; i++)
                {
                    obj2 = children[i];
                    CCSprite sprite2 = obj2 as CCSprite;
                    if (sprite2 != null)
                    {
                        this.removeSpriteFromAtlas(sprite2);
                    }
                }
            }
        }
コード例 #16
0
 public CCAction getActionByTag(uint tag, CCObject target)
 {
     if (this.m_pTargets.ContainsKey(target))
     {
         tHashElement element = this.m_pTargets[target];
         if (element.actions != null)
         {
             int count = element.actions.Count;
             for (int i = 0; i < count; i++)
             {
                 CCAction action = element.actions[i];
                 if (action.tag == tag)
                 {
                     return(action);
                 }
             }
         }
         else
         {
             CCLog.Log("cocos2d : getActionByTag: Target not found");
         }
     }
     else
     {
         CCLog.Log("cocos2d : getActionByTag: Target not found");
     }
     return(null);
 }
コード例 #17
0
 public void removeAllActionsFromTarget(CCObject target)
 {
     if (target != null)
     {
         if (this.m_pTargets.ContainsKey(target))
         {
             tHashElement element = this.m_pTargets[target];
             if (element.actions.Contains(element.currentAction) && !element.currentActionSalvaged)
             {
                 element.currentActionSalvaged = true;
             }
             element.actions.Clear();
             if (this.m_pCurrentTarget == element)
             {
                 this.m_bCurrentTargetSalvaged = true;
             }
             else
             {
                 this.deleteHashElement(element);
             }
         }
         else
         {
             CCLog.Log("cocos2d: removeAllActionsFromTarget: Target not found");
         }
     }
 }
コード例 #18
0
 public void nextCallback(CCObject pSender)
 {
     CCScene s = new EaseActionsTestScene();
     s.addChild(EaseTest.nextEaseAction());
     CCDirector.sharedDirector().replaceScene(s);
     ;
 }
コード例 #19
0
        /// <summary>
        /// Gets an action given its tag an a target
        /// </summary>
        /// <returns>
        /// @return the Action the with the given tag
        /// </returns>
        public CCAction getActionByTag(uint tag, CCObject target)
        {
            Debug.Assert((int)tag != (int)ActionTag.kCCActionTagInvalid);

            if (m_pTargets.ContainsKey(target))
            {
                tHashElement element = m_pTargets[target];

                if (element.actions != null)
                {
                    int limit = element.actions.Count;
                    for (int i = 0; i < limit; i++)
                    {
                        CCAction action = element.actions[i];

                        if (action.tag == (int)tag)
                        {
                            return(action);
                        }
                    }
                }
                else
                {
                    CCLog.Log("cocos2d : getActionByTag: Target not found");
                }
            }
            else
            {
                CCLog.Log("cocos2d : getActionByTag: Target not found");
            }

            return(null);
        }
コード例 #20
0
        /// <summary>
        /// Gets an action given its tag an a target
        /// </summary>
        /// <returns>
        /// @return the Action the with the given tag
        /// </returns>
        public CCAction getActionByTag(uint tag, CCObject target)
        {
            Debug.Assert((int)tag != CCAction.INVALID_ACTION_TAGB);

            if (m_pTargets.ContainsKey(target))
            {
                tHashElement element = m_pTargets[target];

                if (element.actions != null)
                {
                    int limit = element.actions.Count;
                    for (int i = 0; i < limit; i++)
                    {
                        CCAction action = element.actions[i];

                        if (action.Tag == (int)tag)
                        {
                            return(action);
                        }
                    }
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine("cocos2d : getActionByTag: Target not found");
                }
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("cocos2d : getActionByTag: Target not found");
            }

            return(null);
        }
コード例 #21
0
        public void menuCallback(CCObject pSender)
        {
            CCMenuItemFont pItem = (CCMenuItemFont)pSender;
            int nIndex = pItem.zOrder - PerformanceTestScene.kItemTagBasic;

            switch (nIndex)
            {
                case 0:
                    PerformanceNodeChildrenTest.runNodeChildrenTest();
                    break;
                case 1:
                    PerformanceParticleTest.runParticleTest();
                    break;
                case 2:
                    PerformanceSpriteTest.runSpriteTest();
                    break;
                case 3:
                    PerformanceTextureTest.runTextureTest();
                    break;
                case 4:
                    PerformanceTouchesTest.runTouchesTest();
                    break;
                default:
                    break;
            }
        }
コード例 #22
0
ファイル: TileDemo.cs プロジェクト: Ratel13/cocos2d-x-for-xna
        public void restartCallback(CCObject pSender)
        {
            CCScene s = new TileMapTestScene();
            s.addChild(TileMapTestScene.restartTileMapAction()); 

            CCDirector.sharedDirector().replaceScene(s);
        }
コード例 #23
0
        public void restartCallback(CCObject pSender)
        {
            CCScene s = new SpriteTestScene();
            s.addChild(SpriteTestScene.restartSpriteTestAction());

            CCDirector.sharedDirector().replaceScene(s);
        }
コード例 #24
0
 /// <summary>
 /// Resumes the target. All queued actions will be resumed.
 /// </summary>
 public void resumeTarget(CCObject target)
 {
     if (m_pTargets.ContainsKey(target))
     {
         m_pTargets[target].paused = false;
     }
 }
コード例 #25
0
 public void backCallback(CCObject pSender)
 {
     CCScene s = new RenderTextureScene();
     s.addChild(RenderTextureScene.backTestCase());
     CCDirector.sharedDirector().replaceScene(s);
     //s->release();
 }
コード例 #26
0
 public void onPushScene(CCObject pSender)
 {
     CCScene scene = new SceneTestScene();
     CCLayer pLayer = new SceneTestLayer2();
     scene.addChild(pLayer, 0);
     CCDirector.sharedDirector().pushScene(scene);
 }
コード例 #27
0
        public override void RemoveAllChildrenWithCleanup(bool cleanup)
        {
            // Invalidate atlas index. issue #569
            if (Children != null && Children.Count > 0)
            {
                CCObject pObject = null;

                for (int i = 0; i < Children.Count; i++)
                {
                    pObject = Children[i];
                    CCSprite pChild = pObject as CCSprite;

                    if (pChild != null)
                    {
                        removeSpriteFromAtlas(pChild);
                    }
                }
            }

            // http://www.cocos2d-x.org/boards/17/topics/10592
            base.RemoveAllChildrenWithCleanup(cleanup);

            m_pobDescendants.Clear();
            m_pobTextureAtlas.removeAllQuads();
        }
コード例 #28
0
        public virtual void MainMenuCallback(CCObject pSender)
        {
            CCScene pScene = CCScene.node();
            CCLayer pLayer = new TestController();

            pScene.addChild(pLayer);
            CCDirector.sharedDirector().replaceScene(pScene);
        }
コード例 #29
0
 public void btnSettingClickHandle(CCObject sender)
 {
     //CCScene _wolfGameSettingScene = new WolfGameSettingScene();
     //CCDirector.sharedDirector().replaceScene(_wolfGameSettingScene);
     CCScene _wolfGameSettingScene = new WolfGameSettingScene();
     CCScene transScene = CCTransitionZoomFlipX.transitionWithDuration(12f, _wolfGameSettingScene, tOrientation.kOrientationLeftOver);//场景切换特效
     CCDirector.sharedDirector().pushScene(transScene);
 }
コード例 #30
0
        public void backCallback(CCObject pSender)
        {
            CCScene s = new TextInputTestScene();

            s.addChild(textinputTestScene.backTextInputTest());
            CCDirector.sharedDirector().replaceScene(s);
            //s->release();
        }
コード例 #31
0
        public virtual void backCallback(CCObject pSender)
        {
            m_nCurCase--;
            if (m_nCurCase < 0)
                m_nCurCase += m_nMaxCases;

            showCurrentTest();
        }
コード例 #32
0
        public void restartCallback(CCObject pSender)
        {
            CCScene pScene = new SchedulerTestScene();
            CCLayer pLayer = SchedulerTestScene.restartSchedulerTest();

            pScene.addChild(pLayer);
            CCDirector.sharedDirector().replaceScene(pScene);
        }
コード例 #33
0
 public void onReplaceSceneTran(CCObject pSender)
 {
     CCScene pScene = new SceneTestScene();
     CCLayer pLayer = new SceneTestLayer3();
     pScene.addChild(pLayer, 0);
     CCDirector.sharedDirector().replaceScene(pScene);
     //(CCTransitionFlipX.transitionWithDuration(2, pScene));
 }
コード例 #34
0
        public void nextCallback(CCObject pSender)
        {
            CCScene s = new AtlasTestScene();

            s.addChild(AtlasTestScene.nextAtlasAction());

            CCDirector.sharedDirector().replaceScene(s);
        }
コード例 #35
0
 /// <summary>
 /// Removes all actions from all the targets.
 /// </summary>
 public void removeAllActions()
 {
     CCObject[] targets = new CCObject[m_pTargets.Keys.Count];
     m_pTargets.Keys.CopyTo(targets, 0);
     for (int i = 0; i < targets.Length; i++)
     {
         removeAllActionsFromTarget(targets[i]);
     }
 }
コード例 #36
0
        public void onDecrease(CCObject pSender)
        {
            quantityOfNodes -= PerformanceNodeChildrenTest.kNodesIncrease;
            if (quantityOfNodes < 0)
                quantityOfNodes = 0;

            updateQuantityLabel();
            updateQuantityOfNodes();
        }
コード例 #37
0
        public void onIncrease(CCObject pSender)
        {
            quantityOfNodes += PerformanceNodeChildrenTest.kNodesIncrease;
            if (quantityOfNodes > PerformanceNodeChildrenTest.kMaxNodes)
                quantityOfNodes = PerformanceNodeChildrenTest.kMaxNodes;

            updateQuantityLabel();
            updateQuantityOfNodes();
        }
コード例 #38
0
        public void onPushSceneTran(CCObject pSender)
        {
            CCScene scene = new SceneTestScene();
            CCLayer pLayer = new SceneTestLayer2();
            scene.addChild(pLayer, 0);

            CCDirector.sharedDirector().pushScene(scene);
            //(CCTransitionSlideInT.transitionWithDuration(1f, scene));
        }
コード例 #39
0
 public void removeAllActions()
 {
     CCObject[] array = new CCObject[this.m_pTargets.Keys.Count];
     this.m_pTargets.Keys.CopyTo(array, 0);
     for (int i = 0; i < array.Length; i++)
     {
         this.removeAllActionsFromTarget(array[i]);
     }
 }
コード例 #40
0
        public void insertChild(CCSprite pobSprite, int uIndex)
        {
            pobSprite.useBatchNode(this);
            pobSprite.atlasIndex = uIndex;
            pobSprite.dirty      = true;

            if (m_pobTextureAtlas.TotalQuads == m_pobTextureAtlas.Capacity)
            {
                increaseAtlasCapacity();
            }

            ccV3F_C4B_T2F_Quad quad = pobSprite.quad;

            m_pobTextureAtlas.insertQuad(quad, uIndex);
            m_pobDescendants.Insert(uIndex, pobSprite);

            // update indices
            uint i = 0;

            if (m_pobDescendants != null && m_pobDescendants.Count > 0)
            {
                for (int j = 0; j < m_pobDescendants.Count; j++)
                {
                    CCObject pObject = m_pobDescendants[j];
                    CCSprite pChild  = pObject as CCSprite;

                    if (pChild != null)
                    {
                        if (i > uIndex)
                        {
                            pChild.atlasIndex = pChild.atlasIndex + 1;
                        }

                        ++i;
                    }
                }
            }

            // add children recursively
            List <Node> pChildren = pobSprite.Children;

            if (pChildren != null && pChildren.Count > 0)
            {
                for (int j = 0; j < pChildren.Count; j++)
                {
                    CCObject pObject = pChildren[j];
                    CCSprite pChild  = pObject as CCSprite;

                    if (pChild != null)
                    {
                        uIndex = atlasIndexForChild(pChild, pChild.ZOrder);
                        insertChild(pChild, uIndex);
                    }
                }
            }
        }
コード例 #41
0
        public void onQuit(CCObject pSender)
        {
            //getCocosApp()->exit();
            //CCDirector::sharedDirector()->popScene();

            //// HA HA... no more terminate on sdk v3.0
            //// http://developer.apple.com/iphone/library/qa/qa2008/qa1561.html
            //if( [[UIApplication sharedApplication] respondsToSelector:@selector(terminate)] )
            //	[[UIApplication sharedApplication] performSelector:@selector(terminate)];
        }
コード例 #42
0
 public void SettingLanguageCallback(CCObject pSender)
 {
     switch (Platform.QuestionLanguage)
     {
         case Language.Enlish: Platform.QuestionLanguage = Language.Chinese; break;
         case Language.Chinese:
         default: Platform.QuestionLanguage = Language.Enlish; break;
     }
     SceneController.RunScene(EnumScene.Setting);
 }
コード例 #43
0
        /// <summary>
        /// Returns the numbers of actions that are running in a certain target.
        /// Composable actions are counted as 1 action. Example:
        /// - If you are running 1 Sequence of 7 actions, it will return 1.
        /// - If you are running 7 Sequences of 2 actions, it will return 7.
        /// </summary>
        public uint numberOfRunningActionsInTarget(CCObject target)
        {
            if (m_pTargets.ContainsKey(target))
            {
                tHashElement element = m_pTargets[target];
                return((element.actions != null) ? (uint)element.actions.Count : 0);
            }

            return(0);
        }
コード例 #44
0
ファイル: CCCallFuncO.cs プロジェクト: chengcong/cocos2d-xna
 public bool initWithTarget(SelectorProtocol pSelectorTarget, SEL_CallFuncO selector, CCObject pObject)
 {
     if (!base.initWithTarget(pSelectorTarget))
     {
         return(false);
     }
     this.m_pObject    = pObject;
     this.m_pCallFuncO = selector;
     return(true);
 }
コード例 #45
0
        public void update(float dt)
        {
            CCObject[] keys = new CCObject[m_pTargets.Keys.Count];
            m_pTargets.Keys.CopyTo(keys, 0);

            for (int i = 0; i < keys.Length; i++)
            {
                if (!m_pTargets.ContainsKey(keys[i]))
                {
                    // http://www.cocos2d-x.org/boards/17/topics/11072
                    continue;
                }
                tHashElement elt = m_pTargets[keys[i]];
                m_pCurrentTarget         = elt;
                m_bCurrentTargetSalvaged = false;

                if (!m_pCurrentTarget.paused)
                {
                    // The 'actions' may change while inside this loop.
                    for (m_pCurrentTarget.actionIndex = 0; m_pCurrentTarget.actionIndex < m_pCurrentTarget.actions.Count;
                         m_pCurrentTarget.actionIndex++)
                    {
                        m_pCurrentTarget.currentAction = m_pCurrentTarget.actions[m_pCurrentTarget.actionIndex];
                        if (m_pCurrentTarget.currentAction == null)
                        {
                            continue;
                        }

                        m_pCurrentTarget.currentActionSalvaged = false;

                        m_pCurrentTarget.currentAction.Step(dt);

                        if (m_pCurrentTarget.currentAction.IsDone())
                        {
                            m_pCurrentTarget.currentAction.Stop();

                            CCAction action = m_pCurrentTarget.currentAction;
                            // Make currentAction nil to prevent removeAction from salvaging it.
                            m_pCurrentTarget.currentAction = null;
                            removeAction(action);
                        }

                        m_pCurrentTarget.currentAction = null;
                    }
                }

                // only delete currentTarget if no actions were scheduled during the cycle (issue #481)
                if (m_bCurrentTargetSalvaged && m_pCurrentTarget.actions.Count == 0)
                {
                    deleteHashElement(m_pCurrentTarget);
                }
            }

            m_pCurrentTarget = null;
        }
コード例 #46
0
        // todo
        //public static CCCallFuncO actionWithScriptFuncName(string pszFuncName)
        //{
        //    CCCallFuncO pRet = new CCCallFuncO();

        //    if (pRet != null && pRet.initWithScriptFuncName(pszFuncName)) {
        //        return pRet;
        //    }

        //    return null;
        //}

        public bool initWithTarget(SelectorProtocol pSelectorTarget, SEL_CallFuncO selector, CCObject pObject)
        {
            if (base.initWithTarget(pSelectorTarget)) 
            {
		        m_pObject = pObject;
		        m_pCallFuncO = selector;
		        return true;
	        }

	        return false;
        }
コード例 #47
0
ファイル: CCCallFuncO.cs プロジェクト: liwq-net/liwq718
        public static CCCallFuncO actionWithTarget(SelectorProtocol pSelectorTarget, SEL_CallFuncO selector, CCObject pObject)
        {
            CCCallFuncO pRet = new CCCallFuncO();

            if (pRet != null && pRet.initWithTarget(pSelectorTarget, selector, pObject))
            {
                return pRet;
            }

            return null;
        }
コード例 #48
0
        public void backCallback(CCObject pSender)
        {
            // update the action index
            EffectTestScene.actionIdx--;
            int total = MAX_LAYER;
            if (EffectTestScene.actionIdx < 0)
                EffectTestScene.actionIdx += total;

            /*newOrientation();*/
            newScene();
        }
コード例 #49
0
        public static CCCallFuncO actionWithTarget(SelectorProtocol pSelectorTarget,
                                                   SEL_CallFuncO selector, CCObject pObject)
        {
            CCCallFuncO pRet = new CCCallFuncO();

            if (pRet != null && pRet.initWithTarget(pSelectorTarget, selector, pObject))
            {
                return(pRet);
            }

            return(null);
        }
コード例 #50
0
ファイル: CCTMXLayer.cs プロジェクト: liwq-net/liwq718
        private CCSprite insertTileForGID(int gid, CCPoint pos)
        {
            CCRect rect = m_pTileSet.rectForGID(gid);

            rect = new CCRect(rect.origin.x / m_fContentScaleFactor, rect.origin.y / m_fContentScaleFactor, rect.size.width / m_fContentScaleFactor, rect.size.height / m_fContentScaleFactor);

            int z = (int)(pos.x + pos.y * m_tLayerSize.width);

            if (m_pReusedTile == null)
            {
                m_pReusedTile = new CCSprite();
                m_pReusedTile.initWithBatchNode(this, rect);
            }
            else
            {
                m_pReusedTile = new CCSprite();
                m_pReusedTile.initWithBatchNode(this, rect);
            }
            m_pReusedTile.positionInPixels = positionAt(pos);
            m_pReusedTile.vertexZ          = (float)vertexZForPos(pos);
            m_pReusedTile.anchorPoint      = new CCPoint(0, 0);
            m_pReusedTile.Opacity          = m_cOpacity;

            // get atlas index
            int indexForZ = atlasIndexForNewZ(z);

            // Optimization: add the quad without adding a child
            this.addQuadFromSprite(m_pReusedTile, indexForZ);

            // insert it into the local atlasindex array
            ccCArray.ccCArrayInsertValueAtIndex(m_pAtlasIndexArray, z, indexForZ);

            // update possible children
            if (m_pChildren != null && m_pChildren.Count > 0)
            {
                CCObject pObject = null;

                for (int i = 0; i < m_pChildren.Count; i++)
                {
                    CCSprite pChild = (CCSprite)pObject;
                    if (pChild != null)
                    {
                        int ai = pChild.atlasIndex;
                        if (ai >= indexForZ)
                        {
                            pChild.atlasIndex = ai + 1;
                        }
                    }
                }
            }
            m_pTiles[z] = gid;
            return(m_pReusedTile);
        }
コード例 #51
0
        public void restartCallback(CCObject pSender)
        {
            CCScene s = new TransitionsTestScene();
            CCLayer pLayer = new TestLayer2();
            s.addChild(pLayer);

            CCScene pScene = TransitionsTestScene.createTransition(TransitionsTestScene.s_nSceneIdx, TransitionsTestScene.TRANSITION_DURATION, s);
            if (pScene != null)
            {
                CCDirector.sharedDirector().replaceScene(pScene);
            }
        }
コード例 #52
0
        public void backCallback(CCObject pSender)
        {
            CCLayer pLayer = backHiResAction();

            if (pLayer != null)
            {
                CCScene pScene = new HiResTestScene();
                pScene.addChild(pLayer);

                CCDirector.sharedDirector().replaceScene(pScene);
            }
        }
コード例 #53
0
        public uint numberOfRunningActionsInTarget(CCObject target)
        {
            if (!this.m_pTargets.ContainsKey(target))
            {
                return(0);
            }
            tHashElement element = this.m_pTargets[target];

            if (element.actions == null)
            {
                return(0);
            }
            return((uint)element.actions.Count);
        }
コード例 #54
0
ファイル: CCTMXLayer.cs プロジェクト: liwq-net/liwq718
        /// <summary>
        /// removes a tile at given tile coordinate
        /// </summary>
        public void removeTileAt(CCPoint pos)
        {
            Debug.Assert(pos.x < m_tLayerSize.width && pos.y < m_tLayerSize.height && pos.x >= 0 && pos.y >= 0, "TMXLayer: invalid position");
            Debug.Assert(m_pTiles != null && m_pAtlasIndexArray != null, "TMXLayer: the tiles map has been released");

            int gid = tileGIDAt(pos);

            if (gid != 0)
            {
                int z          = (int)(pos.x + pos.y * m_tLayerSize.width);
                int atlasIndex = atlasIndexForExistantZ(z);

                // remove tile from GID map
                m_pTiles[z] = 0;

                // remove tile from atlas position array
                ccCArray.ccCArrayRemoveValueAtIndex(m_pAtlasIndexArray, atlasIndex);

                // remove it from sprites and/or texture atlas
                CCSprite sprite = (CCSprite)getChildByTag((int)z);
                if (sprite != null)
                {
                    base.removeChild(sprite, true);
                }
                else
                {
                    m_pobTextureAtlas.removeQuadAtIndex(atlasIndex);

                    // update possible children
                    if (m_pChildren != null && m_pChildren.Count > 0)
                    {
                        CCObject pObject = null;
                        for (int i = 0; i < m_pChildren.Count; i++)
                        {
                            CCSprite pChild = (CCSprite)pObject;
                            if (pChild != null)
                            {
                                int ai = pChild.atlasIndex;
                                if (ai >= atlasIndex)
                                {
                                    pChild.atlasIndex = ai - 1;
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #55
0
        public void insertChild(CCSprite pobSprite, int uIndex)
        {
            pobSprite.useBatchNode(this);
            pobSprite.atlasIndex = uIndex;
            pobSprite.dirty      = true;
            if (this.m_pobTextureAtlas.TotalQuads == this.m_pobTextureAtlas.Capacity)
            {
                this.increaseAtlasCapacity();
            }
            ccV3F_C4B_T2F_Quad quad = pobSprite.quad;

            this.m_pobTextureAtlas.insertQuad(quad, uIndex);
            this.m_pobDescendants.Insert(uIndex, pobSprite);
            uint num = 0;

            if ((this.m_pobDescendants != null) && (this.m_pobDescendants.Count > 0))
            {
                for (int i = 0; i < this.m_pobDescendants.Count; i++)
                {
                    CCObject obj2   = this.m_pobDescendants[i];
                    CCSprite sprite = obj2 as CCSprite;
                    if (sprite != null)
                    {
                        if (num > uIndex)
                        {
                            sprite.atlasIndex++;
                        }
                        num++;
                    }
                }
            }
            List <CCNode> children = pobSprite.children;

            if ((children != null) && (children.Count > 0))
            {
                for (int j = 0; j < children.Count; j++)
                {
                    CCObject obj3    = children[j];
                    CCSprite sprite2 = obj3 as CCSprite;
                    if (sprite2 != null)
                    {
                        uIndex = this.atlasIndexForChild(sprite2, sprite2.zOrder);
                        this.insertChild(sprite2, uIndex);
                    }
                }
            }
        }
コード例 #56
0
 public void removeActionByTag(int tag, CCObject target)
 {
     if (this.m_pTargets.ContainsKey(target))
     {
         tHashElement element = this.m_pTargets[target];
         int          count   = element.actions.Count;
         for (int i = 0; i < count; i++)
         {
             CCAction action = element.actions[i];
             if ((action.tag == tag) && (action.originalTarget == target))
             {
                 this.removeActionAtIndex(i, element);
                 return;
             }
         }
     }
 }
コード例 #57
0
        public int rebuildIndexInOrder(CCSprite pobParent, int uIndex)
        {
            List <Node> pChildren = pobParent.Children;

            if (pChildren != null && pChildren.Count > 0)
            {
                CCObject pObject = null;

                for (int i = 0; i < pChildren.Count; i++)
                {
                    pObject = pChildren[i];
                    CCSprite pChild = pObject as CCSprite;

                    if (pChild != null && (pChild.ZOrder < 0))
                    {
                        uIndex = rebuildIndexInOrder(pChild, uIndex);
                    }
                }
            }

            // ignore self (batch node)
            if (!pobParent.Equals(this))
            {
                pobParent.atlasIndex = uIndex;
                uIndex++;
            }

            if (pChildren != null && pChildren.Count > 0)
            {
                CCObject pObject = null;

                for (int i = 0; i < pChildren.Count; i++)
                {
                    pObject = pChildren[i];
                    CCSprite pChild = pObject as CCSprite;

                    if (pChild != null && (pChild.ZOrder >= 0))
                    {
                        uIndex = rebuildIndexInOrder(pChild, uIndex);
                    }
                }
            }

            return(uIndex);
        }
コード例 #58
0
ファイル: CCTMXLayer.cs プロジェクト: chengcong/cocos2d-xna
        private CCSprite insertTileForGID(int gid, CCPoint pos)
        {
            CCRect cCRect = this.m_pTileSet.rectForGID(gid);

            cCRect = new CCRect(cCRect.origin.x / this.m_fContentScaleFactor, cCRect.origin.y / this.m_fContentScaleFactor, cCRect.size.width / this.m_fContentScaleFactor, cCRect.size.height / this.m_fContentScaleFactor);
            int num = (int)(pos.x + pos.y * this.m_tLayerSize.width);

            if (this.m_pReusedTile != null)
            {
                this.m_pReusedTile = new CCSprite();
                this.m_pReusedTile.initWithBatchNode(this, cCRect);
            }
            else
            {
                this.m_pReusedTile = new CCSprite();
                this.m_pReusedTile.initWithBatchNode(this, cCRect);
            }
            this.m_pReusedTile.positionInPixels = this.positionAt(pos);
            this.m_pReusedTile.vertexZ          = (float)this.vertexZForPos(pos);
            this.m_pReusedTile.anchorPoint      = new CCPoint(0f, 0f);
            this.m_pReusedTile.Opacity          = this.m_cOpacity;
            int num1 = this.atlasIndexForNewZ(num);

            base.addQuadFromSprite(this.m_pReusedTile, num1);
            ccCArray.ccCArrayInsertValueAtIndex(this.m_pAtlasIndexArray, num, num1);
            if (this.m_pChildren != null && this.m_pChildren.Count > 0)
            {
                CCObject cCObject = null;
                for (int i = 0; i < this.m_pChildren.Count; i++)
                {
                    CCSprite cCSprite = (CCSprite)cCObject;
                    if (cCSprite != null)
                    {
                        int num2 = cCSprite.atlasIndex;
                        if (num2 >= num1)
                        {
                            cCSprite.atlasIndex = num2 + 1;
                        }
                    }
                }
            }
            this.m_pTiles[num] = gid;
            return(this.m_pReusedTile);
        }
コード例 #59
0
 public override void removeAllChildrenWithCleanup(bool cleanup)
 {
     if ((base.m_pChildren != null) && (base.m_pChildren.Count > 0))
     {
         CCObject obj2 = null;
         for (int i = 0; i < base.m_pChildren.Count; i++)
         {
             obj2 = base.m_pChildren[i];
             CCSprite pobSprite = obj2 as CCSprite;
             if (pobSprite != null)
             {
                 this.removeSpriteFromAtlas(pobSprite);
             }
         }
     }
     base.removeAllChildrenWithCleanup(cleanup);
     this.m_pobDescendants.Clear();
     this.m_pobTextureAtlas.removeAllQuads();
 }
コード例 #60
0
        protected void deleteHashElement(tHashElement element)
        {
            element.actions.Clear();
            element.target = null;
            CCObject key = null;

            foreach (KeyValuePair <CCObject, tHashElement> pair in this.m_pTargets)
            {
                if (element == pair.Value)
                {
                    key = pair.Key;
                    break;
                }
            }
            if (key != null)
            {
                this.m_pTargets.Remove(key);
            }
        }