Beispiel #1
0
        public TMXReadWriteTest() : base("TileMaps/orthogonal-test2")
        {
            m_gid = CCTileGidAndFlags.EmptyTile;

            CCTileMapLayer layer = tileMap.LayerNamed("Layer 0");
            layer.Antialiased = true;

            tileMap.Scale = (1);

            CCSprite tile0 = layer.ExtractTile(1, 63);
            CCSprite tile1 = layer.ExtractTile(2, 63);
            CCSprite tile2 = layer.ExtractTile(3, 62); //new CCPoint(1,62));
            CCSprite tile3 = layer.ExtractTile(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 sequence = new CCSequence(move, rotate, scale, opacity, fadein, scaleback, finish);

			tile0.RunAction(sequence);
			tile1.RunAction(sequence);
			tile2.RunAction(sequence);
			tile3.RunAction(sequence);


            m_gid = layer.TileGIDAndFlags(0, 63);

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


            m_gid2 = CCTileGidAndFlags.EmptyTile;
        }
Beispiel #2
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);
        }
        void OnTouchesEnded(List<CCTouch> touches, CCEvent touchEvent)
        {
            var monstersToDelete = new List<CCNode>();

            var touch = touches[0];
            var touchLocation = Layer.ScreenToWorldspace(touch.LocationOnScreen);

            foreach(var monster in _monstersOnScreen)
            {
                if(monster.BoundingBox.ContainsPoint(touchLocation))
                {
                    monstersToDelete.Add(monster);

                    var m = _monsters[monster.Tag];
                    var splashPool = new CCSprite(m.SplashSprite);

                    if(m.KillMethod == 1)
                    {
                        splashPool.Position = monster.Position;
                        AddChild(splashPool);

                        var fade = new CCFadeOut(3.0f);
                        var remove = new CCCallFuncN (RemoveSprite);
                        var sequencia = new CCSequence(fade, remove);
                        CCSimpleAudioEngine.SharedEngine.EffectsVolume = 0.7f;
                        CCSimpleAudioEngine.SharedEngine.PlayEffect("Sounds/SplatEffect");
                        splashPool.RunAction(sequencia);
                    }
                    else if(m.KillMethod == 2)
                    {
                        CCSimpleAudioEngine.SharedEngine.EffectsVolume = 1.0f;
                        CCSimpleAudioEngine.SharedEngine.PlayEffect("Sounds/pew-pew-lei");

                        splashPool.Position = monster.Position;
                        AddChild(splashPool);

                        var fade = new CCFadeOut(3.0f);
                        var particleEmitter = new CCCallFuncND(StartExplosion, monster);
                        var sequencia = new CCSequence(particleEmitter, fade);
                        CCSimpleAudioEngine.SharedEngine.EffectsVolume = 0.7f;
                        CCSimpleAudioEngine.SharedEngine.PlayEffect("Sounds/SplatEffect");
                        splashPool.RunAction(sequencia);
                    }
                    break;
                }
            }

            foreach(var monster in monstersToDelete)
            {
                monster.StopAllActions();
                _monstersOnScreen.Remove(monster);
                RemoveChild(monster);
            }
        }
Beispiel #4
0
        public Issue1327()
        {
            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);

            actF = new CCSequence(act1, act2, act3, act4, act5, act6, act7, act8, act9);
        }
Beispiel #5
0
        /// <summary>
        /// 初始化缩放
        /// </summary>
        /// <param name="_scaleForm"></param>
        /// <param name="_scaleTo"></param>
        /// <param name="_duration"></param>
        private void InitScale(float _scaleForm = 1.0f, float _scaleTo = 1.1f, float _duration = 0.1f)
        {
            m_scaleFunc = new CCCallFuncN(node => ((BaseButton)node).ScaleComplete());

            ScaleTo = _scaleTo;
            ScaleFrom = _scaleForm;
            ScaleDuration = _duration;
        }
        private void AddMonster(float time)
        {
            var selectedMonster = new Random().Next() % _monsters.Count;

            var monster = _monsters[selectedMonster];
            var m = monster.Movement;

            //!IMPORTANT -- Every Sprite in Screen must be an new CCSprite! Each Sprite can only be one time on screen
            var spriteMonster = new CCSprite(monster.MonsterSprite);
            spriteMonster.Scale = _appScale;
            spriteMonster.Tag = monster.Tag;

            //BLOCK 1 - Determine where to spawn the monster along the Y axis
            var winSize = Window.WindowSizeInPixels;
            var minX = (spriteMonster.ContentSize.Width / 2);
            var maxX = winSize.Width - spriteMonster.ContentSize.Width / 2;
            var rangeX = maxX - minX;
            var actualY = (new Random().Next() % rangeX) + minX;

            //BLOCK 2 - Determine speed of the monster
            var minDuration = monster.MinVelocity;
            var maxDuration = monster.MaxVelocity;
            var rangeDuration = maxDuration - minDuration;
            var actualDuration = (new Random().Next() % rangeDuration) + minDuration;

            if(m == 1)
            {
                spriteMonster.Position = new CCPoint(actualY, winSize.Height + spriteMonster.ContentSize.Height/2);
                AddChild(spriteMonster);

                var actionMove = new CCMoveTo(actualDuration, new CCPoint(actualY, -spriteMonster.ContentSize.Height/2));
                var actionMoveComplete = new CCCallFuncN (node =>
                    {
                        _monstersOnScreen.Remove(node);
                        node.RemoveFromParent();

                        _lives--;
                        var index = _hearths.Count - 1;
                        RemoveChild(_hearths[index]);
                        _hearths.RemoveAt(index);
                        if(_lives == 0)
                        {
                            Window.DefaultDirector.ReplaceScene(GameStartLayer.GameStartLayerScene(Window));
                        }
                    });

                spriteMonster.RunActions(actionMove, actionMoveComplete);
                _monstersOnScreen.Add(spriteMonster);
            }
            else if(m == 2)
            {
                spriteMonster.Position = new CCPoint(actualY, winSize.Height + spriteMonster.ContentSize.Height/2);
                AddChild(spriteMonster);

                var actionMoveComplete = new CCCallFuncN (node =>
                    {
                        _monstersOnScreen.Remove(node);
                        node.RemoveFromParent();

                        _lives--;
                        var index = _hearths.Count - 1;
                        RemoveChild(_hearths[index]);
                        _hearths.RemoveAt(index);
                        if(_lives == 0)
                        {
                            Window.DefaultDirector.ReplaceScene(GameStartLayer.GameStartLayerScene(Window));
                        }
                    });

                var bezierList = new List<CCFiniteTimeAction>();
                var bezier = new CCBezierConfig();
                var splitDuration = actualDuration / 6.0f;
                CCBezierTo bezierAction;

                for(int i = 0; i < 6; i++)
                {
                    if(i % 2 == 0)
                    {
                        bezier.ControlPoint1 = new CCPoint(actualY + 100, winSize.Height - (100 + (i * 200)));
                        bezier.ControlPoint2 = new CCPoint(actualY + 100, winSize.Height - (100 + (i * 200)));
                        bezier.EndPosition = new CCPoint(actualY, winSize.Height - (200 + (i * 200)));
                        bezierAction = new CCBezierTo(splitDuration, bezier);
                    }
                    else
                    {
                        bezier.ControlPoint1 = new CCPoint(actualY - 100, winSize.Height - (100 + (i * 200)));
                        bezier.ControlPoint2 = new CCPoint(actualY - 100, winSize.Height - (100 + (i * 200)));
                        bezier.EndPosition = new CCPoint(actualY, winSize.Height - (200 + (i * 200)));
                        bezierAction = new CCBezierTo(splitDuration, bezier);
                    }

                    bezierList.Add(bezierAction);
                }

                bezierList.Add(actionMoveComplete);

                var seq = new CCSequence(bezierList.ToArray());
                spriteMonster.RunAction(seq);

                _monstersOnScreen.Add(spriteMonster);
            }
        }
Beispiel #7
0
 public CCCallFuncNState(CCCallFuncN action, CCNode target)
     : base(action, target)
 {
     CallFunctionN = action.CallFunctionN;
 }
Beispiel #8
0
 public CCCallFuncNState (CCCallFuncN action, CCNode target)
     : base(action, target)
 {   
     CallFunctionN = action.CallFunctionN;
 }
        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];

                    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()));
        }
Beispiel #10
0
        public TMXReadWriteTest()
        {
            m_gid = 0;

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

            CCTMXLayer layer = map.LayerNamed("Layer 0");
			layer.IsAntialiased = true;

            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 sequence = new CCSequence(move, rotate, scale, opacity, fadein, scaleback, finish);

			tile0.RunAction(sequence);
			tile1.RunAction(sequence);
			tile2.RunAction(sequence);
			tile3.RunAction(sequence);


            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;
        }
Beispiel #11
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];

					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());
		}