示例#1
0
        public TMXReadWriteTest()
        {
            m_gid = 0;

            CCTMXTiledMap map = CCTMXTiledMap.Create("TileMaps/orthogonal-test2");
            AddChild(map, 0, kTagTileMap);

            CCTMXLayer layer = map.LayerNamed("Layer 0");
            layer.Texture.SetAntiAliasTexParameters();

            map.Scale = (1);

            CCSprite tile0 = layer.TileAt(new CCPoint(1, 63));
            CCSprite tile1 = layer.TileAt(new CCPoint(2, 63));
            CCSprite tile2 = layer.TileAt(new CCPoint(3, 62)); //new CCPoint(1,62));
            CCSprite tile3 = layer.TileAt(new CCPoint(2, 62));
            tile0.AnchorPoint = (new CCPoint(0.5f, 0.5f));
            tile1.AnchorPoint = (new CCPoint(0.5f, 0.5f));
            tile2.AnchorPoint = (new CCPoint(0.5f, 0.5f));
            tile3.AnchorPoint = (new CCPoint(0.5f, 0.5f));

            CCMoveBy move = new CCMoveBy (0.5f, new CCPoint(0, 160));
            CCRotateBy rotate = new CCRotateBy (2, 360);
            CCScaleBy scale = new CCScaleBy(2, 5);
            CCFadeOut opacity = new CCFadeOut  (2);
            CCFadeIn fadein = new CCFadeIn  (2);
            CCScaleTo scaleback = new CCScaleTo(1, 1);
            CCCallFuncN finish = new CCCallFuncN(removeSprite);
            CCSequence seq0 = new CCSequence(move, rotate, scale, opacity, fadein, scaleback, finish);
            var seq1 = (CCActionInterval) (seq0.Copy());
            var seq2 = (CCActionInterval) (seq0.Copy());
            var seq3 = (CCActionInterval) (seq0.Copy());

            tile0.RunAction(seq0);
            tile1.RunAction(seq1);
            tile2.RunAction(seq2);
            tile3.RunAction(seq3);


            m_gid = layer.TileGIDAt(new CCPoint(0, 63));
            ////----UXLOG("Tile GID at:(0,63) is: %d", m_gid);

            Schedule(updateCol, 2.0f);
            Schedule(repaintWithGID, 2.0f);
            Schedule(removeTiles, 1.0f);

            ////----UXLOG("++++atlas quantity: %d", layer.textureAtlas().getTotalQuads());
            ////----UXLOG("++++children: %d", layer.getChildren().count() );

            m_gid2 = 0;
        }
示例#2
0
 public CCCallFuncN(CCCallFuncN callFuncN) : base(callFuncN)
 {
     InitWithTarget(callFuncN.m_pCallFuncN);
 }
示例#3
0
        public override void OnEnter()
        {
            base.OnEnter();

            centerSprites(0);

            var spr = new CCSprite("Images/grossini");
            spr.Position = new CCPoint(100, 100);
            AddChild(spr);

            var act1 = new CCCallFuncN(logSprRotation);
            var act2 = new CCRotateBy (0.25f, 45);
            var act3 = new CCCallFuncN(logSprRotation);
            var act4 = new CCRotateBy (0.25f, 45);
            var act5 = new CCCallFuncN(logSprRotation);
            var act6 = new CCRotateBy (0.25f, 45);
            var act7 = new CCCallFuncN(logSprRotation);
            var act8 = new CCRotateBy (0.25f, 45);
            var act9 = new CCCallFuncN(logSprRotation);

            var actF = new CCSequence(act1, act2, act3, act4, act5, act6, act7, act8, act9);
            spr.RunAction(actF);
        }
示例#4
0
        public Object ActionForCallbackChannel(CCBSequenceProperty channel)
        {
            float lastKeyframeTime = 0;

            var actions      = new List <CCFiniteTimeAction>();
            var keyframes    = channel.Keyframes;
            int numKeyframes = keyframes.Count;

            for (int i = 0; i < numKeyframes; ++i)
            {
                CCBKeyframe keyframe = keyframes[i];
                float       timeSinceLastKeyframe = keyframe.Time - lastKeyframeTime;
                lastKeyframeTime = keyframe.Time;
                if (timeSinceLastKeyframe > 0)
                {
                    actions.Add(new CCDelayTime(timeSinceLastKeyframe));
                }

                var           keyVal         = (List <CCBValue>)keyframe.Value;
                string        selectorName   = keyVal[0].GetStringValue();
                CCBTargetType selectorTarget =
                    (CCBTargetType)int.Parse(keyVal[1].GetStringValue());

                if (_jsControlled)
                {
                    string     callbackName = string.Format("{0}:{1}", selectorTarget, selectorName);
                    CCCallFunc callback     = (CCCallFunc)_keyframeCallFuncs[callbackName].Copy();

                    if (callback != null)
                    {
                        actions.Add(callback);
                    }
                }
                else
                {
                    Object target = null;

                    if (selectorTarget == CCBTargetType.DocumentRoot)
                    {
                        target = _rootNode;
                    }
                    else if (selectorTarget == CCBTargetType.Owner)
                    {
                        target = _owner;
                    }

                    if (target != null)
                    {
                        if (selectorName.Length > 0)
                        {
                            Action <CCNode> selCallFunc = null;

                            ICCBSelectorResolver targetAsCCBSelectorResolver = target as ICCBSelectorResolver;

                            if (targetAsCCBSelectorResolver != null)
                            {
                                selCallFunc = targetAsCCBSelectorResolver.OnResolveCCBCCCallFuncSelector(target,
                                                                                                         selectorName);
                            }

                            if (selCallFunc == null)
                            {
                                CCLog.Log("Skipping selector {0} since no CCBSelectorResolver is present.",
                                          selectorName);
                            }
                            else
                            {
                                CCCallFuncN callback = new CCCallFuncN(selCallFunc);
                                actions.Add(callback);
                            }
                        }
                        else
                        {
                            CCLog.Log("Unexpected empty selector.");
                        }
                    }
                }
            }
            if (actions.Capacity < 1)
            {
                return(null);
            }

            return(new CCSequence(actions.ToArray()));
        }
示例#5
0
        /**
     * Sets a new content offset. It ignores max/min offset. It just sets what's given. (just like UIKit's UIScrollView)
     * You can override the animation duration with this method.
     *
     * @param offset new offset
     * @param animation duration
     */

        public void SetContentOffsetInDuration(CCPoint offset, float dt)
        {
            CCMoveTo scroll = new CCMoveTo (dt, offset);
            CCCallFuncN expire = new CCCallFuncN(StoppedAnimatedScroll);
            _container.RunAction(new CCSequence(scroll, expire));
            Schedule(PerformedAnimatedScroll);
        }
示例#6
0
        public Object ActionForCallbackChannel(CCBSequenceProperty channel)
        {
            float lastKeyframeTime = 0;

            var actions = new List<CCFiniteTimeAction>();
            var keyframes = channel.Keyframes;
            int numKeyframes = keyframes.Count;

            for (int i = 0; i < numKeyframes; ++i)
            {

                CCBKeyframe keyframe = keyframes[i];
                float timeSinceLastKeyframe = keyframe.Time - lastKeyframeTime;
                lastKeyframeTime = keyframe.Time;
                if (timeSinceLastKeyframe > 0)
                {
                    actions.Add(new CCDelayTime(timeSinceLastKeyframe));
                }

                var keyVal = (List<CCBValue>)keyframe.Value;
                string selectorName = keyVal[0].GetStringValue();
                CCBTargetType selectorTarget =
                    (CCBTargetType) int.Parse(keyVal[1].GetStringValue());

                if (_jsControlled)
                {
                    string callbackName = string.Format("{0}:{1}", selectorTarget, selectorName);
                    CCCallFunc callback = (CCCallFunc) _keyframeCallFuncs[callbackName].Copy();

                    if (callback != null)
                    {
                        actions.Add(callback);
                    }
                }
                else
                {
                    Object target = null;

                    if (selectorTarget == CCBTargetType.DocumentRoot)
                        target = _rootNode;
                    else if (selectorTarget == CCBTargetType.Owner)
                        target = _owner;

                    if (target != null)
                    {
                        if (selectorName.Length > 0)
                        {
                            Action<CCNode> selCallFunc = null;

                            ICCBSelectorResolver targetAsCCBSelectorResolver = target as ICCBSelectorResolver;

                            if (targetAsCCBSelectorResolver != null)
                            {
                                selCallFunc = targetAsCCBSelectorResolver.OnResolveCCBCCCallFuncSelector(target,
                                                                                                          selectorName);
                            }

                            if (selCallFunc == null)
                            {
                                CCLog.Log("Skipping selector {0} since no CCBSelectorResolver is present.",
                                      selectorName);
                            }
                            else
                            {
                                CCCallFuncN callback = new CCCallFuncN(selCallFunc);
                                actions.Add(callback);
                            }
                        }
                        else
                        {
                            CCLog.Log("Unexpected empty selector.");
                        }
                    }
                }
            }
            if (actions.Capacity < 1) return null;

            return new CCSequence(actions.ToArray());
        }
        private void addRemoteBanana(float x)
        {
            Console.WriteLine ("addRemoteBanana");
            var banana = new CCSprite ("BananaRemote");

            banana.Position = new CCPoint (x, banana.ContentSize.Height / 2);

            AddChild (banana);

            var moveBanana = new CCMoveTo (5.0f, new CCPoint (banana.Position.X, CCDirector.SharedDirector.WinSize.Height));

            var moveBananaComplete = new CCCallFuncN ((node) => {
                node.RemoveFromParentAndCleanup (true);
            });

            var moveBananaSequence = new CCSequence (moveBanana, moveBananaComplete);

            banana.RunAction (moveBananaSequence);
        }
        CCSprite AddLocalBanana()
        {
            var banana = new CCSprite ("BananaLocal");
            banana.Tag = 0;
            double rnd = new Random ().NextDouble ();
            double randomX = (rnd > 0)
                ? rnd * CCDirector.SharedDirector.WinSize.Width - banana.ContentSize.Width / 2
                : banana.ContentSize.Width / 2;

            banana.Position = new CCPoint ((float)randomX, CCDirector.SharedDirector.WinSize.Height - banana.ContentSize.Height / 2);

            byte[] message = buildBananaMessage ((float)randomX);
            sendWarpUpdate (message);

            AddChild (banana);

            var moveBanana = new CCMoveTo (5.0f, new CCPoint (banana.Position.X, 0));

            var moveBananaComplete = new CCCallFuncN ((node) => {
                node.RemoveFromParentAndCleanup (true);
                localBananas.Remove(banana);
            });

            var moveBananaSequence = new CCSequence (moveBanana, moveBananaComplete);

            banana.RunAction (moveBananaSequence);

            return banana;
        }