示例#1
0
        /** switches to a certain layer indexed by n.
         * The current (old) layer will be removed from it's parent with 'cleanup:YES'.
         */

        /// <summary>
        /// Swtich to the given index layer and use the given action after the layer is
        /// added to the scene.
        /// </summary>
        /// <param name="n"></param>
        public void SwitchTo(int n)
        {
            Debug.Assert(n < m_pLayers.Count, "Invalid index in MultiplexLayer switchTo message");

            CCLayer outLayer = m_pLayers[m_nEnabledLayer];

            if (m_OutAction != null)
            {
                outLayer.RunAction(
                    CCSequence.FromActions(
                        (CCFiniteTimeAction)m_OutAction.Copy(),
                        new CCCallFunc(() => RemoveChild(outLayer, true))
                        )
                    );
            }
            else
            {
                RemoveChild(outLayer, true);
            }

            m_nEnabledLayer = n;

            AddChild(m_pLayers[n]);

            if (m_InAction != null)
            {
                m_pLayers[n].RunAction(m_InAction.Copy());
            }
        }
 public void SwitchToNone()
 {
     if (m_nEnabledLayer != -1)
     {
         CCLayer outLayer = null;
         if (m_pLayers.ContainsKey(m_nEnabledLayer))
         {
             outLayer = m_pLayers[m_nEnabledLayer];
             if (m_OutAction != null)
             {
                 outLayer.RunAction(
                     new CCSequence(
                         (CCFiniteTimeAction)m_OutAction.Copy(),
                         new CCCallFunc(() => RemoveChild(outLayer, true))
                         )
                     );
             }
             else
             {
                 RemoveChild(outLayer, true);
             }
         }
     }
     // We have no enabled layer at this point
     m_nEnabledLayer = -1;
 }
示例#3
0
        public StressTest2()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            CCLayer sublayer = new CCLayer();

            CCSprite sp1 = new CCSprite(TestResource.s_pPathSister1);
            sp1.Position = (new CCPoint(80, s.Height / 2));

            CCActionInterval move = new CCMoveBy (3, new CCPoint(350, 0));
            CCActionInterval move_ease_inout3 = new CCEaseInOut((CCActionInterval) (move.Copy()), 2.0f);
            var move_ease_inout_back3 = (CCActionInterval) move_ease_inout3.Reverse();
            CCFiniteTimeAction seq3 = new CCSequence(move_ease_inout3, move_ease_inout_back3);
            sp1.RunAction(new CCRepeatForever ((CCActionInterval) seq3));
            sublayer.AddChild(sp1, 1);

            CCParticleFire fire = new CCParticleFire();
            fire.Texture = (CCTextureCache.SharedTextureCache.AddImage("Images/fire"));
            fire.Position = (new CCPoint(80, s.Height / 2 - 50));

            var copy_seq3 = (CCActionInterval) (seq3.Copy());

            fire.RunAction(new CCRepeatForever (copy_seq3));
            sublayer.AddChild(fire, 2);

            Schedule((shouldNotLeak), 6.0f);

            AddChild(sublayer, 0, CocosNodeTestStaticLibrary.kTagSprite1);
        }
        public override void runThisTest()
        {
            CCLayer pLayer = nextTextInputTest();

            AddChild(pLayer);

            CCDirector.SharedDirector.ReplaceScene(this);
        }
 public bool InitWithLayer(CCLayer layer)
 {
     m_pLayers = new List<CCLayer>(1);
     m_pLayers.Add(layer);
     m_nEnabledLayer = 0;
     AddChild(layer);
     return true;
 }
        /// <summary>
        /// Switches to the new layer and removes the old layer from management.
        /// </summary>
        /// <param name="n"></param>
        /// <returns></returns>
        public CCLayer SwitchToAndReleaseMe(int n)
        {
            var     prevLayer = m_nEnabledLayer;
            CCLayer l         = SwitchTo(n);

            m_pLayers[prevLayer] = null;
            return(l);
        }
 public bool InitWithLayer(CCLayer layer)
 {
     m_pLayers = new List <CCLayer>(1);
     m_pLayers.Add(layer);
     m_nEnabledLayer = 0;
     AddChild(layer);
     return(true);
 }
 private bool InitWithLayer(CCLayer layer)
 {
     m_pLayers = new Dictionary <int, CCLayer>();
     m_pLayers[m_pLayers.Count] = layer;
     if (layer.Tag != CCNode.kCCNodeTagInvalid)
     {
         m_pLayers[layer.Tag + kTagOffsetForUniqueness] = layer;
     }
     return(true);
 }
示例#9
0
 private bool InitWithLayer(CCLayer layer)
 {
     m_pLayers = new Dictionary<int,CCLayer>();
     m_pLayers[m_pLayers.Count] = layer;
     if (layer.Tag != CCNode.kCCNodeTagInvalid)
     {
         m_pLayers[layer.Tag + kTagOffsetForUniqueness] = layer;
     }
     return true;
 }
示例#10
0
        public override void OnEnter()
        {
            base.OnEnter();

            this.TouchEnabled = true;

            CCSize s = CCDirector.SharedDirector.WinSize;

            CCLayerColor layer1 = new CCLayerColor(new CCColor4B(0xFF, 0xFF, 0x00, 0x80), s.Width * 0.75f, s.Height * 0.75f);
            layer1.IgnoreAnchorPointForPosition = false;
            layer1.Position = (new CCPoint(s.Width / 2, s.Height / 2));
            layer1.ChildClippingMode = CCClipMode.Bounds;
            AddChild(layer1, 1);

            s = layer1.ContentSize;

            m_pInnerLayer = new CCLayerColor(new CCColor4B(0xFF, 0x00, 0x00, 0x80), s.Width * 0.5f, s.Height * 0.5f);
            m_pInnerLayer.IgnoreAnchorPointForPosition = false;
            m_pInnerLayer.Position = (new CCPoint(s.Width / 2, s.Height / 2));
            m_pInnerLayer.ChildClippingMode = CCClipMode.Bounds;
            
            layer1.AddChild(m_pInnerLayer, 1);
            
            //
            // Add two labels using BM label class
            // CCLabelBMFont
            CCLabelBMFont label1 = new CCLabelBMFont("LABEL1", "fonts/konqa32.fnt");
            label1.Position = new CCPoint(m_pInnerLayer.ContentSize.Width, m_pInnerLayer.ContentSize.Height * 0.75f);
            m_pInnerLayer.AddChild(label1);
            
            CCLabelBMFont label2 = new CCLabelBMFont("LABEL2", "fonts/konqa32.fnt");
            label2.Position = new CCPoint(0, m_pInnerLayer.ContentSize.Height * 0.25f);
            m_pInnerLayer.AddChild(label2);

            float runTime = 12f;

            CCScaleTo scaleTo2 = new CCScaleTo(runTime * 0.25f, 3.0f);
            CCScaleTo scaleTo3 = new CCScaleTo(runTime * 0.25f, 1.0f);

            CCFiniteTimeAction seq = new CCRepeatForever(
                new CCSequence(scaleTo2, scaleTo3)
                );

            m_pInnerLayer.RunAction(seq);

            CCSize size = CCDirector.SharedDirector.WinSize;

            var move1 = new CCMoveTo(2, new CCPoint(size.Width / 2, size.Height));
            var move2 = new CCMoveTo(2, new CCPoint(size.Width, size.Height / 2));
            var move3 = new CCMoveTo(2, new CCPoint(size.Width / 2, 0));
            var move4 = new CCMoveTo(2, new CCPoint(0, size.Height / 2));

            layer1.RunAction(new CCRepeatForever(new CCSequence(move1, move2, move3, move4)));

        }
示例#11
0
 public void AddLayer(CCLayer layer)
 {
     if (m_pLayers == null)
     {
         InitWithLayer(layer);
     }
     else
     {
         m_pLayers.Add(layer);
     }
 }
示例#12
0
 private bool InitWithLayer(CCLayer layer)
 {
     m_pLayers = new Dictionary<int,CCLayer>();
     int ix = m_pLayers.Count;
     m_pLayers[ix] = layer;
     _LayersInOrder.Add(ix);
     if (layer.Tag != CCNode.kCCNodeTagInvalid)
     {
         m_pLayers[layer.Tag + kTagOffsetForUniqueness] = layer;
     }
     return true;
 }
示例#13
0
        private bool InitWithLayer(CCLayer layer)
        {
            m_pLayers = new Dictionary <int, CCLayer>();
            int ix = m_pLayers.Count;

            m_pLayers[ix] = layer;
            _LayersInOrder.Add(ix);
            if (layer.Tag != CCNode.kCCNodeTagInvalid)
            {
                m_pLayers[layer.Tag + kTagOffsetForUniqueness] = layer;
            }
            return(true);
        }
示例#14
0
        public SchedulerTest1()
        {
            CCLayer layer = new CCLayer();
            //UXLOG("retain count after init is %d", layer->retainCount());                // 1

            AddChild(layer, 0);
            //UXLOG("retain count after addChild is %d", layer->retainCount());      // 2

            layer.Schedule((doSomething));
            //UXLOG("retain count after schedule is %d", layer->retainCount());      // 3 : (object-c viersion), but win32 version is still 2, because CCTimer class don't save target.

            layer.Unschedule((doSomething));
            //UXLOG("retain count after unschedule is %d", layer->retainCount());		// STILL 3!  (win32 is '2')
        }
 public void AddLayer(CCLayer layer)
 {
     if (m_pLayers == null)
     {
         InitWithLayer(layer);
     }
     else
     {
         m_pLayers[m_pLayers.Count] = layer;
         if (layer.Tag != CCNode.kCCNodeTagInvalid)
         {
             m_pLayers[layer.Tag + kTagOffsetForUniqueness] = layer;
         }
     }
 }
示例#16
0
 /// <summary>
 /// Adds the given layer to the list of layers to multiplex. The CCNode.Tag is used
 /// as thelayer tag, but is offset by the kTagOffsetForUniqueness constant.
 /// </summary>
 /// <param name="layer"></param>
 public void AddLayer(CCLayer layer)
 {
     if (m_pLayers == null)
     {
         InitWithLayer(layer);
     }
     else
     {
         int ix = m_pLayers.Count;
         m_pLayers[ix] = layer;
         _LayersInOrder.Add(ix);
         if (layer.Tag != CCNode.kCCNodeTagInvalid)
         {
             m_pLayers[layer.Tag + kTagOffsetForUniqueness] = layer;
         }
     }
 }
示例#17
0
        public override void OnEnter()
        {
            base.OnEnter();

            Color = CCTypes.CCBlack;
            RemoveChild(m_background, true);
            m_background = null;

            m_emitter = new CCParticleSystemQuad("Particles/LavaFlow");
            m_emitter.Texture = CCTextureCache.SharedTextureCache.AddImage("Images/fire");
            CCParticleBatchNode batch = new CCParticleBatchNode(m_emitter.Texture);

            batch.AddChild(m_emitter);

            AddChild(batch, 10);

            Schedule(switchRender, 2.0f);

            CCLayer node = new CCLayer();
            AddChild(node);

            m_pParent1 = batch;
            m_pParent2 = node;
        }
 public CCLayerMultiplex(CCAction inAction, CCAction outAction, CCLayer layer)
 {
     InitWithLayer(layer);
     m_InAction = inAction;
     m_OutAction = outAction;
 }
示例#19
0
 public LayerMultiplexTest()
 {
     for (int i = 0; i < 3; i++)
     {
         CCLayer l = new CCLayer();
         CCSprite img = null;
         switch (i)
         {
             case 0:
                 img = new CCSprite("Images/grossini");
                 break;
             case 1:
                 img = new CCSprite("Images/grossinis_sister1");
                 break;
             case 2:
                 img = new CCSprite("Images/grossinis_sister2");
                 break;
         }
         img.AnchorPoint = CCPoint.Zero;
         img.Position = CCPoint.Zero;
         l.AddChild(img);
         l.AnchorPoint = new CCPoint(0.5f, 0.5f);
         l.Position = new CCPoint(1024/2f, 768/2f);
         child.AddLayer(l);
     }
     child.InAction = new CCFadeIn(1);
     AddChild(child);
     Schedule(new Action<float>(AutoMultiplex), 3f);
 }
 public CCLayerMultiplex(CCAction inAction, CCAction outAction, CCLayer layer)
 {
     InitWithLayer(layer);
     m_InAction  = inAction;
     m_OutAction = outAction;
 }
示例#21
0
 private bool InitWithLayer(CCLayer layer)
 {
     m_pLayers = new List<CCLayer>();
     m_pLayers.Add(layer);
     return true;
 }
 /// <summary>
 /// Swtich to the given index layer and use the given action after the layer is
 /// added to the parent. The parameter can be the index or it can be the tag of the layer.
 /// </summary>
 /// <param name="n">Send in NoLayer to hide all multiplexed layers. Otherwise, send in a tag or the logical index of the
 /// layer to show.</param>
 /// <returns>The layer that is going to be shown. This can return null if the SwitchTo layer is NoLayer</returns>
 public CCLayer SwitchTo(int n)
 {
     if (n != -1)
     {
         if (m_nEnabledLayer == n || m_nEnabledLayer == (n + kTagOffsetForUniqueness))
         {
             // no-op
             if (m_nEnabledLayer == -1)
             {
                 return(null);
             }
             return(m_pLayers[m_nEnabledLayer]);
         }
     }
     if (m_nEnabledLayer != -1)
     {
         CCLayer outLayer = null;
         if (m_pLayers.ContainsKey(m_nEnabledLayer))
         {
             outLayer = m_pLayers[m_nEnabledLayer];
             if (m_OutAction != null)
             {
                 outLayer.RunAction(
                     new CCSequence(
                         (CCFiniteTimeAction)m_OutAction.Copy(),
                         new CCCallFunc(() => RemoveChild(outLayer, true))
                         )
                     );
             }
             else
             {
                 RemoveChild(outLayer, true);
             }
         }
         // We have no enabled layer at this point
         m_nEnabledLayer = NoLayer;
     }
     // When NoLayer, the multiplexer shows nothing.
     if (n == NoLayer)
     {
         ShowFirstLayerOnEnter = false;
         return(null);
     }
     if (!m_pLayers.ContainsKey(n))
     {
         int f = n + kTagOffsetForUniqueness;
         if (m_pLayers.ContainsKey(f))
         {
             n = f;
         }
         else
         {
             // Invalid index - layer not found
             return(null);
         }
     }
     // Set the active layer
     AddChild(m_pLayers[n]);
     m_nEnabledLayer = n;
     // Run the in-action on the new layer
     if (m_InAction != null)
     {
         m_pLayers[n].RunAction(m_InAction.Copy());
     }
     return(m_pLayers[m_nEnabledLayer]);
 }
示例#23
0
 /// <summary>
 ///  * lua script can not init with undetermined number of variables
 /// * so add these functinons to be used with lua.
 /// </summary>
 /// <param name="layer"></param>
 /// <returns></returns>
 public CCLayerMultiplex (CCLayer layer)
 {
     InitWithLayer(layer);
 }
示例#24
0
 public void AddLayer(CCLayer layer)
 {
     Debug.Assert(m_pLayers != null);
     m_pLayers.Add(layer);
 }
 /// <summary>
 /// Adds the given layer to the list of layers to multiplex. The CCNode.Tag is used
 /// as thelayer tag, but is offset by the kTagOffsetForUniqueness constant.
 /// </summary>
 /// <param name="layer"></param>
 public void AddLayer(CCLayer layer)
 {
     if (m_pLayers == null)
     {
         InitWithLayer(layer);
     }
     else
     {
         m_pLayers[m_pLayers.Count] = layer;
         _LayersInOrder.Add(m_pLayers.Count);
         if (layer.Tag != CCNode.kCCNodeTagInvalid)
         {
             m_pLayers[layer.Tag + kTagOffsetForUniqueness] = layer;
         }
     }
 }
 /// <summary>
 ///  * lua script can not init with undetermined number of variables
 /// * so add these functinons to be used with lua.
 /// </summary>
 /// <param name="layer"></param>
 /// <returns></returns>
 public CCLayerMultiplex(CCLayer layer)
 {
     InitWithLayer(layer);
 }
 public void AddLayer(CCLayer layer)
 {
     Debug.Assert(m_pLayers != null);
     m_pLayers.Add(layer);
 }