Example #1
0
        public CCShuffleTilesState (CCShuffleTiles action, CCNode target) : base (action, target)
        {
            CCGridSize gridSize = action.GridSize;
            TilesCount = gridSize.X * gridSize.Y;
            int[] shuffledTilesOrder = new int[TilesCount];
            int i, j, f = 0;

            for (i = 0; i < TilesCount; i++) {
                shuffledTilesOrder [i] = i;
            }

            if (action.Seed != CCShuffleTiles.NoSeedSpecified) {
                CCRandom.Next (action.Seed);
            }


            Shuffle (ref shuffledTilesOrder, TilesCount);
            TilesOrder = shuffledTilesOrder;

            Tiles = new CCTile[TilesCount];

            for (i = 0; i < gridSize.X; ++i) {
                for (j = 0; j < gridSize.Y; ++j) {
                    Tiles [f] = new CCTile {
                        Position = new CCPoint (i, j),
                        StartPosition = new CCPoint (i, j),
                        Delta = GetDelta (i, j)
                    };

                    f++;
                }
            }
        }
Example #2
0
 public CCFiniteTimeActionState (CCFiniteTimeAction action, CCNode target)
     : base (action, target)
 { 
     Duration = action.Duration;
     Elapsed = 0.0f;
     firstTick = true;
 }
Example #3
0
 public CCLens3DState (CCLens3D action, CCNode target) : base (action, target)
 {
     Position = action.Position;
     Radius = action.Radius;
     LensScale = action.LensScale;
     Concave = action.Concave;
 }
Example #4
0
        protected override void AddedToScene()
        {
            base.AddedToScene();

            contentLayer = new CCLayer();
            Window.IsUseDepthTesting = true;
            node = new CCNode(Layer.VisibleBoundsWorldspace.Size);
            node.AnchorPoint = CCPoint.AnchorMiddle;
            node.IgnoreAnchorPointForPosition = true;

            AddChild(contentLayer);
            contentLayer.AddChild(node);

            dir = 1;
            time = 0;
            sprites = new CCSprite[numOfSprites];


            for (int i = 0; i < 5; i++)
            {
                CCSprite sprite = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 0, 121 * 1, 85, 121));
                node.AddChild(sprite, 0);
                sprites[i] = sprite;
            }

            for (int i = 5; i < 11; i++)
            {
                CCSprite sprite = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 1, 121 * 0, 85, 121));
                node.AddChild(sprite, 0);
                sprites[i] = sprite;
            }
        }
Example #5
0
 public bool InitWithCcPoint(CCPoint ratio, CCPoint offset)
 {
     Ratio = ratio;
     Offset = offset;
     Child = null;
     return true;
 }
        public CCRotateAroundToState(CCRotateAroundTo action, CCNode target)
            : base(action, target)
        { 
            DistanceAngle = action.DistanceAngle;

            Origin = action.Origin;
            StartPosition = target.Position;
            RotationDirection = action.RotationDirection;

            offsetX = StartPosition.X - Origin.X;
            offsetY = StartPosition.Y - Origin.Y;

            // Calculate the Starting Angle of the target in relation to the Origin in which it is to rotate

            // Math.Atan2 returns the mathematical angle which is counter-clockwise [-Math.PI, +Math.PI]
            StartAngle = CCMathHelper.ToDegrees((float)Math.Atan2(offsetY, offsetX));
            // Map value [0,360]
            StartAngle = (StartAngle + 360) % 360;


            // Now we work out how far we actually have to rotate
            DiffAngle = DistanceAngle - StartAngle;
            // Map value [0,360] and take into consideration the direction of rotation - CCW or CW
            DiffAngle = (DiffAngle + 360 * RotationDirection) % 360;

            theta = CCMathHelper.ToRadians(DiffAngle);


        }
Example #7
0
        public override void OnEnter()
        {
            base.OnEnter();

			var effect = new CCSequence(new CCDelayTime (2.0f), new CCShaky3D(5.0f, new CCGridSize(5, 5), 16, false));

            // cleanup
			RemoveChild(bgNode, true);

            // background
			var layer = new CCLayerColor(new CCColor4B(255, 0, 0, 255));
            AddChild(layer, -10);
			var sprite = new CCSprite("Images/grossini");
            sprite.Position = new CCPoint(50, 80);
            layer.AddChild(sprite, 10);

            // foreground
			var layer2Node = new CCNode ();
			var layer2 = new CCLayerColor(new CCColor4B(0, 255, 0, 255));
			var fog = new CCSprite("Images/Fog");

			var bf = new CCBlendFunc {Source = CCOGLES.GL_SRC_ALPHA, Destination = CCOGLES.GL_ONE_MINUS_SRC_ALPHA};
			fog.BlendFunc = bf;
			layer2.AddChild(fog, 1);
			AddChild(layer2Node, 1);
			layer2Node.AddChild (layer2);

			layer2Node.RepeatForever(effect);
        }
Example #8
0
 protected override void OnHandlePropTypeCheck(CCNode node, CCNode parent, string propertyName, bool pCheck, CCBReader reader)
 {
     if (propertyName == PROPERTY_TOUCH_ENABLED)
     {
         ((CCLayer) node).TouchEnabled = pCheck;
     }
     else if (propertyName == PROPERTY_ACCELEROMETER_ENABLED)
     {
         ((CCLayer) node).AccelerometerEnabled = pCheck;
     }
     else if (propertyName == PROPERTY_MOUSE_ENABLED)
     {
         // TODO XXX
         CCLog.Log("The property '{0}' is not supported!", PROPERTY_MOUSE_ENABLED);
     }
     else if (propertyName == PROPERTY_KEYBOARD_ENABLED)
     {
         // TODO XXX
         CCLog.Log("The property '{0}' is not supported!", PROPERTY_KEYBOARD_ENABLED);
         // This comes closest: ((CCLayer *)node).setKeypadEnabled(pCheck);
     }
     else
     {
         base.OnHandlePropTypeCheck(node, parent, propertyName, pCheck, reader);
     }
 }
Example #9
0
		public TextLayer() : base()
		{

            contentLayer = new CCLayer();
            CCCamera contentCamera = Camera;
            contentLayer.Camera = contentCamera;

            var bg = new CCSprite(TestResource.s_back3);
            BaseNode = bg;
            contentLayer.AddChild(bg, 0, EffectTestScene.kTagBackground);

            var Kathia = new CCSprite(TestResource.s_pPathSister2);
            BaseNode.AddChild(Kathia, 1, EffectTestScene.kTagKathia);

            var sc = new CCScaleBy(2, 5);
            var sc_back = sc.Reverse();
            Kathia.RunAction(new CCRepeatForever(sc, sc_back));


            var Tamara = new CCSprite(TestResource.s_pPathSister1);
            BaseNode.AddChild(Tamara, 1, EffectTestScene.kTagTamara);

            var sc2 = new CCScaleBy(2, 5);
            var sc2_back = sc2.Reverse();
            Tamara.RunAction(new CCRepeatForever(sc2, sc2_back));

            var colorBackground = new CCLayerColor(new CCColor4B(32, 128, 32, 255));
            contentLayer.AddChild(colorBackground, -1);
		}
Example #10
0
 public override void StartWithTarget(CCNode target)
 {
     base.StartWithTarget(target);
     m_sConfig.ControlPoint1 = CCPointExtension.Subtract(m_sConfig.ControlPoint1, m_startPosition);
     m_sConfig.ControlPoint2 = CCPointExtension.Subtract(m_sConfig.ControlPoint2, m_startPosition);
     m_sConfig.EndPosition = CCPointExtension.Subtract(m_sConfig.EndPosition, m_startPosition);
 }
Example #11
0
        public CCTileMap(CCTileMapInfo mapInfo)
            : base(CCCameraProjection.Projection2D)
        {
            Type = mapInfo.MapType;
            MapDimensions = mapInfo.MapDimensions;
            MapInfo = mapInfo;
            TileTexelSize = mapInfo.TileTexelSize;

            ObjectGroups = mapInfo.ObjectGroups;
            MapProperties = mapInfo.MapProperties;
            TileProperties = mapInfo.TileProperties;

            TileLayersContainer
                = new CCNode(MapDimensions.Size * TileTexelSize * CCTileMapLayer.DefaultTexelToContentSizeRatios);

            AddChild(TileLayersContainer);

            int idx = 0;

            List<CCTileLayerInfo> layers = mapInfo.Layers;
            if (layers != null)
            {
                foreach (CCTileLayerInfo layerInfo in layers)
                {
                    if (layerInfo.Visible)
                    {
                        CCTileSetInfo[] tilesets = TilesetsForLayer(layerInfo);
                        CCTileMapLayer child = new CCTileMapLayer(tilesets, layerInfo, mapInfo);
                        TileLayersContainer.AddChild(child, idx, idx);

                        idx++;
                    }
                }
            }
        }
Example #12
0
        public SpriteZVertex()
        {
            //
            // This test tests z-order
            // If you are going to use it is better to use a 3D projection
            //
            // WARNING:
            // The developer is resposible for ordering it's sprites according to it's Z if the sprite has
            // transparent parts.
            //

            dir = 1;
            time = 0;
            sprites = new CCSprite[numOfSprites];

            node = new CCNode();
            AddChild(node, 0);

            for (int i = 0; i < 5; i++)
            {
                CCSprite sprite = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 0, 121 * 1, 85, 121));
                node.AddChild(sprite, 0);
                sprites[i] = sprite;
            }

            for (int i = 5; i < 11; i++)
            {
                CCSprite sprite = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 1, 121 * 0, 85, 121));
                node.AddChild(sprite, 0);
                sprites[i] = sprite;
            }
        }
Example #13
0
 public override void startWithTarget(CCNode target)
 {
     base.startWithTarget(target);
     m_sConfig.controlPoint_1 = CCPointExtension.ccpSub(m_sConfig.controlPoint_1, m_startPosition);
     m_sConfig.controlPoint_2 = CCPointExtension.ccpSub(m_sConfig.controlPoint_2, m_startPosition);
     m_sConfig.endPosition = CCPointExtension.ccpSub(m_sConfig.endPosition, m_startPosition);
 }
            public Button(string text)
                : this()
            {
                child = new CCLabel(text, "arial", 16, CCLabelFormat.SystemFont);
                AddChild(child);

            }
Example #15
0
        public override void StartWithTarget(CCNode target)
        {
            base.StartWithTarget(target);

            m_fStartAngle = target.Rotation;

            if (m_fStartAngle > 0)
            {
                m_fStartAngle = m_fStartAngle % 350.0f;
            }
            else
            {
                m_fStartAngle = m_fStartAngle % -360.0f;
            }

            m_fDiffAngle = m_fDstAngle - m_fStartAngle;
            if (m_fDiffAngle > 180)
            {
                m_fDiffAngle -= 360;
            }

            if (m_fDiffAngle < -180)
            {
                m_fDiffAngle += 360;
            }
        }
        public override void OnEnter ()
        {
            base.OnEnter ();

            var origin = Layer.VisibleBoundsWorldspace.Size;

            var label1 = new CCLabel(string.Empty, "debuguncompressed", 0, CCLabelFormat.SpriteFont);

            var texture = label1.TextureAtlas != null ? label1.TextureAtlas.Texture : null;

            if (texture != null) {
                spriteFontNode = new CCSprite (texture);
                spriteFontNode.Scale = 2;
            }
            else
            {
                spriteFontNode = new CCLabel("Texture can not be loaded", "arial", 24, CCLabelFormat.SpriteFont);
            }
            //spriteFontNode.Color = CCColor3B.Magenta;
            spriteFontNode.Position = origin.Center;


            AddChild (spriteFontNode);

            var itemUncompressed = new CCMenuItemLabel(new CCLabel("Uncompressed", "fonts/arial", 24, CCLabelFormat.SpriteFont));
            var itemCompressed = new CCMenuItemLabel(new CCLabel("Compressed", "fonts/arial", 24, CCLabelFormat.SpriteFont));
            itemUncompressed.AnchorPoint = CCPoint.AnchorMiddleLeft;
            itemCompressed.AnchorPoint = CCPoint.AnchorMiddleLeft;
            var mi1 = new CCMenuItemToggle(OnToggle, itemUncompressed, itemCompressed);
            var menu = new CCMenu(mi1);

            AddChild(menu);
            menu.Position = VisibleBoundsWorldspace.Left();
        }
Example #17
0
		public CCGridActionState (CCGridAction action, CCNode target) : base (action, target)
		{
			GridSize = action.GridSize;
			CCGridBase targetGrid = Target.Grid;

			if (targetGrid != null && targetGrid.ReuseGrid > 0)
			{
				Grid = targetGrid;

				if (targetGrid.Active && targetGrid.GridSize.X == GridSize.X && targetGrid.GridSize.Y == GridSize.Y)
				{
					targetGrid.Reuse ();
				}
				else
				{
					Debug.Assert (false);
				}
			}
			else
			{
				if (targetGrid != null && targetGrid.Active)
				{
					targetGrid.Active = false;
				}

				CCGridBase newgrid = Grid;

				Target.Grid = newgrid;
				Target.Grid.Active = true;
			}
		}
        public override void OnEnter()
        {
            base.OnEnter();

            CCSize screenSize = Layer.VisibleBoundsWorldspace.Size;

            // Defines an array of title to create buttons dynamically
            var stringArray = new[] {
                "Hello",
                "Variable",
                "Size",
                "!"
            };

            CCNode layer = new CCNode ();
            AddChild(layer, 1);

            float total_width = 0, height = 0;

            // For each title in the array
            int i = 0;
            foreach(var title in stringArray)
            {
                // Creates a button with this string as title
                var button = standardButtonWithTitle(title);
                if (i == 0)
                {
                    button.Opacity = 50;
                    button.Color = new CCColor3B(0, 255, 0);
                }
                else if (i == 1)
                {
                    button.Opacity = 200;
                    button.Color = new CCColor3B(0, 255, 0);
                }
                else if (i == 2)
                {
                    button.Opacity = 100;
                    button.Color = new CCColor3B(0, 0, 255);
                }

                button.Position = new CCPoint (total_width + button.ContentSize.Width / 2, button.ContentSize.Height / 2);
                layer.AddChild(button);

                // Compute the size of the layer
                height = button.ContentSize.Height;
                total_width += button.ContentSize.Width;
                i++;
            }

            layer.AnchorPoint = new CCPoint(0.5f, 0.5f);
            layer.ContentSize = new CCSize(total_width, height);
            layer.Position = new CCPoint(screenSize.Width / 2.0f, screenSize.Height / 2.0f);

            // Add the black background
            var background = new CCScale9SpriteFile("extensions/buttonBackground");
            background.ContentSize = new CCSize(total_width + 14, height + 14);
            background.Position = new CCPoint(screenSize.Width / 2.0f, screenSize.Height / 2.0f);
            AddChild(background);
        }
        public SpriteChildrenVisibilityIssue665()
        {
            CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFrames("animations/grossini.plist");


            aParent = new CCSpriteBatchNode("animations/grossini", 50);
            AddChild(aParent, 0);

            sprite1 = new CCSprite("grossini_dance_01.png");
            sprite2 = new CCSprite("grossini_dance_02.png");
            sprite3 = new CCSprite("grossini_dance_03.png");

            // test issue #665
            sprite1.Visible = false;

            aParent.AddChild(sprite1);
            sprite1.AddChild(sprite2, -2);
            sprite1.AddChild(sprite3, 2);

            aParent2 = new CCNode();
            AddChild(aParent2, 0);

            sprite4 = new CCSprite("grossini_dance_01.png");
            sprite5 = new CCSprite("grossini_dance_02.png");
            sprite6 = new CCSprite("grossini_dance_03.png");

            // test issue #665
            sprite4.Visible = false;

            aParent2.AddChild(sprite4);
            sprite4.AddChild(sprite5, -2);
            sprite4.AddChild(sprite6, 2);
        }
Example #20
0
 protected override void OnHandlePropTypeSpriteFrame(CCNode node, CCNode parent, string propertyName, CCSpriteFrame spriteFrame,
                                                     CCBReader reader)
 {
     if (propertyName == PROPERTY_NORMALDISPLAYFRAME)
     {
         if (spriteFrame != null)
         {
             ((CCMenuItemImage)node).NormalImageSpriteFrame = spriteFrame;
         }
     }
     else if (propertyName == PROPERTY_SELECTEDDISPLAYFRAME)
     {
         if (spriteFrame != null)
         {
             ((CCMenuItemImage)node).SelectedImageSpriteFrame = spriteFrame;
         }
     }
     else if (propertyName == PROPERTY_DISABLEDDISPLAYFRAME)
     {
         if (spriteFrame != null)
         {
             ((CCMenuItemImage) node).DisabledImageSpriteFrame = spriteFrame;
         }
     }
     else
     {
         base.OnHandlePropTypeSpriteFrame(node, parent, propertyName, spriteFrame, reader);
     }
 }
Example #21
0
 public override void StartWithTarget(CCNode target)
 {
     m_uTotal = 0;
     m_fNextDt = m_pInnerAction.Duration / m_fDuration;
     base.StartWithTarget(target);
     m_pInnerAction.StartWithTarget(target);
 }
        async void StressIt (float dt)
        {

            if (this.NumberOfRunningActions > 0)
                return;
            
            var targetNode = new CCNodeGrid();
            AddChild(targetNode);

            //lbl = new CCSprite("images/bat2.png");
            label1 = CreateLabel (string.Format("Score: {0:n0} - Level: {1}", 123456, count), 30, CCColor3B.Yellow, CCColor3B.Blue);
            label1.Position = this.ContentSize.Center;
            targetNode.AddChild(label1);
            count++;

            await targetNode.RunActionAsync(fadeOut);

            // Make sure we unset our grid that was attached.
            targetNode.Grid = null;

            label1.RemoveFromParent();
            label1 = null; 

            targetNode.RemoveFromParent();

//            GC.Collect ();
//            GC.WaitForPendingFinalizers ();
//            GC.Collect ();
        }
Example #23
0
 protected internal override void StartWithTarget(CCNode target)
 {
     base.StartWithTarget(target);
     m_sConfig.ControlPoint1 = (m_sConfig.ControlPoint1 - m_startPosition);
     m_sConfig.ControlPoint2 = (m_sConfig.ControlPoint2 - m_startPosition);
     m_sConfig.EndPosition = (m_sConfig.EndPosition - m_startPosition);
 }
        public static CCNode CreateLabel(string text, float size, CCColor3B color, CCColor3B shadowColor)
        {
            var node = new CCNode () {
                AnchorPoint = CCPoint.AnchorMiddle,
            };


            size *= 1.2f;

            var lbl = new CCLabel(text, "fonts/MorrisRoman-Black.ttf", size, CCLabelFormat.SystemFont)
                {
                    Color = color,
                    AnchorPoint = CCPoint.AnchorMiddle,
                };
            lbl.LabelFormat.Alignment = CCTextAlignment.Center;

            node.ContentSize = lbl.ScaledContentSize;
            lbl.Position = node.ContentSize.Center;

            if (shadowColor != CCColor3B.Magenta)
            {
                node.ContentSize = lbl.ContentSize + 2;
                var shadowLbl = new CCLabel (text, "fonts/MorrisRoman-Black.ttf", size, CCLabelFormat.SystemFont) {
                    Color = shadowColor,
                    AnchorPoint = CCPoint.AnchorMiddle,
                    Position = new CCPoint(node.ContentSize.Center.X + 2, node.ContentSize.Center.Y - 2)
                };
                shadowLbl.LabelFormat.Alignment = CCTextAlignment.Center;
                node.AddChild (shadowLbl);
            }
            node.AddChild (lbl);
            return node;
        }
Example #25
0
		public TextLayer() : base()
		{

            Camera = AppDelegate.SharedCamera;
            contentLayer = new CCLayer();
            CCCamera contentCamera = new CCCamera(Camera.OrthographicViewSizeWorldspace, Camera.CenterInWorldspace, Camera.TargetInWorldspace);
            contentLayer.Camera = contentCamera;

            var bg = new CCSprite(TestResource.s_back3);
            BaseNode = bg;
            contentLayer.AddChild(bg, 0, EffectTestScene.kTagBackground);

            var Kathia = new CCSprite(TestResource.s_pPathSister2);
            BaseNode.AddChild(Kathia, 1, EffectTestScene.kTagKathia);

            var sc = new CCScaleBy(2, 5);
            var sc_back = sc.Reverse();
            Kathia.RunAction(new CCRepeatForever(sc, sc_back));


            var Tamara = new CCSprite(TestResource.s_pPathSister1);
            BaseNode.AddChild(Tamara, 1, EffectTestScene.kTagTamara);

            var sc2 = new CCScaleBy(2, 5);
            var sc2_back = sc2.Reverse();
            Tamara.RunAction(new CCRepeatForever(sc2, sc2_back));

            var colorBackground = new CCLayerColor(new CCColor4B(32, 128, 32, 255));
            contentLayer.AddChild(colorBackground, -1);
		}
Example #26
0
		public NodeToWorld3D()
		{
			//
			// This code tests that nodeToParent works OK:
			//  - It tests different anchor Points
			//  - It tests different children anchor points

			parent = new CCNode();
			parent.AnchorPoint = new CCPoint(0.5f, 0.5f);
			AddChild(parent);

			back = new CCSprite(TestResource.s_back3);
			parent.AddChild(back, -10);
			back.AnchorPoint = CCPoint.Zero;


			var item = new CCMenuItemImage(TestResource.s_PlayNormal, TestResource.s_PlaySelect);
			menu = new CCMenu(item);
			menu.AlignItemsVertically();

			back.AddChild(menu);

			item.RepeatForever(CocosNodeTestStaticLibrary.nodeRotate);

			back.RepeatForever(CocosNodeTestStaticLibrary.nodeMove, CocosNodeTestStaticLibrary.nodeMove.Reverse());

			parent.RunAction (CocosNodeTestStaticLibrary.nodeOrbit);
		}
Example #27
0
        public CCActionState GetActionState(int tag, CCNode target)
        {
            Debug.Assert(tag != (int)CCActionTag.Invalid);

            // Early out if we do not have any targets to search
            if (targets.Count == 0)
                return null;

            HashElement element;
            if (targets.TryGetValue(target, out element))
            {
                if (element.ActionStates != null)
                {
                    int limit = element.ActionStates.Count;
                    for (int i = 0; i < limit; i++)
                    {
                        var actionState = element.ActionStates[i];

                        if (actionState.Action.Tag == tag)
                        {
                            return actionState;
                        }
                    }
                    CCLog.Log("CocosSharp : GetActionStateByTag: Tag " + tag + " not found");
                }
            }
            else
            {
                CCLog.Log("CocosSharp : GetActionStateByTag: Target not found");
            }
            return null;
        }
Example #28
0
 public override void StartWithTarget(CCNode target)
 {
     base.StartWithTarget(target);
     m_fStartScaleX = target.ScaleX;
     m_fStartScaleY = target.ScaleY;
     m_fDeltaX = m_fEndScaleX - m_fStartScaleX;
     m_fDeltaY = m_fEndScaleY - m_fStartScaleY;
 }
Example #29
0
 protected internal override void StartWithTarget(CCNode target)
 {
     base.StartWithTarget(target);
     m_fDeltaX = m_fSkewX;
     m_fDeltaY = m_fSkewY;
     m_fEndSkewX = m_fStartSkewX + m_fDeltaX;
     m_fEndSkewY = m_fStartSkewY + m_fDeltaY;
 }
Example #30
0
 public CCJumpByState (CCJumpBy action, CCNode target)
     : base (action, target)
 { 
     Delta = action.Position;
     Height = action.Height;
     Jumps = action.Jumps;
     P = StartPosition = target.Position;
 }
Example #31
0
 public override void StartWithTarget(CCNode target)
 {
     base.StartWithTarget(target);
     m_startPosition = target.Position;
     m_delta         = (m_endPosition - m_startPosition);
 }
Example #32
0
 public CCShowState(CCShow action, CCNode target)
     : base(action, target)
 {
     target.Visible = true;
 }
Example #33
0
 protected internal override void StartWithTarget(CCNode target)
 {
     base.StartWithTarget(target);
     m_winSize = CCDirector.SharedDirector.WinSizeInPixels;
 }
Example #34
0
 public Button(string text)
     : this()
 {
     child = new CCLabel(text, "arial", 16, CCLabelFormat.SystemFont);
     AddChild(child);
 }
Example #35
0
 public override void AddChild(CCNode child, int zOrder, int tag)
 {
     Debug.Assert(false, "ParallaxNode: use addChild:z:parallaxRatio:positionOffset instead");
 }
Example #36
0
 public override void StartWithTarget(CCNode target)
 {
     base.StartWithTarget(target);
     m_pTarget.Position = m_tPosition;
 }
Example #37
0
 public void bugMe(CCNode node)
 {
     node.StopAllActions(); //After this stop next action not working, if remove this stop everything is working
     node.RunAction(new CCScaleTo(2, 2));
 }
Example #38
0
 public CCTwirlState(CCTwirl action, CCNode target) : base(action, target)
 {
     Twirls           = action.Twirls;
     PositionInPixels = action.Position;
 }
Example #39
0
 protected internal override CCActionState StartAction(CCNode target)
 {
     return(new CCTwirlState(this, target));
 }
Example #40
0
        public TextLayer()
        {
            InitWithColor(CCTypes.CreateColor(32, 32, 32, 255));

            float x, y;

            CCSize size = CCDirector.SharedDirector.WinSize;

            x = size.Width;
            y = size.Height;


            CCNode           node   = new CCNode();
            CCActionInterval effect = getAction();

            node.RunAction(effect);
            AddChild(node, 0, EffectTestScene.kTagBackground);

            CCSprite bg = new CCSprite(TestResource.s_back3);

            node.AddChild(bg, 0);
            bg.AnchorPoint = new CCPoint(0.5f, 0.5f);
            bg.Position    = new CCPoint(size.Width / 2, size.Height / 2);

            CCSprite grossini = new CCSprite(TestResource.s_pPathSister2);

            node.AddChild(grossini, 1);
            grossini.Position = new CCPoint(x / 3, y / 2);
            CCActionInterval   sc      = new CCScaleBy(2, 5);
            CCFiniteTimeAction sc_back = sc.Reverse();

            grossini.RunAction(new CCRepeatForever((CCActionInterval)(CCSequence.FromActions(sc, sc_back))));
            //grossini.runAction(effect);

            CCSprite tamara = new CCSprite(TestResource.s_pPathSister1);

            node.AddChild(tamara, 1);
            tamara.Position = new CCPoint(2 * x / 3, y / 2);
            CCActionInterval   sc2      = new CCScaleBy(2, 5);
            CCFiniteTimeAction sc2_back = sc2.Reverse();

            tamara.RunAction(new CCRepeatForever((CCActionInterval)(CCSequence.FromActions(sc2, sc2_back))));

            CCLabelTTF label = new CCLabelTTF(EffectTestScene.effectsList[EffectTestScene.actionIdx], "arial", 32);

            label.Position = new CCPoint(x / 2, y - 80);
            AddChild(label);
            label.Tag = EffectTestScene.kTagLabel;

            CCMenuItemImage item1 = new CCMenuItemImage(TestResource.s_pPathB1, TestResource.s_pPathB2, backCallback);
            CCMenuItemImage item2 = new CCMenuItemImage(TestResource.s_pPathR1, TestResource.s_pPathR2, restartCallback);
            CCMenuItemImage item3 = new CCMenuItemImage(TestResource.s_pPathF1, TestResource.s_pPathF2, nextCallback);

            CCMenu menu = new CCMenu(item1, item2, item3);

            menu.Position  = new CCPoint(0, 0);
            item1.Position = new CCPoint(size.Width / 2 - 100, 30);
            item2.Position = new CCPoint(size.Width / 2, 30);
            item3.Position = new CCPoint(size.Width / 2 + 100, 30);

            AddChild(menu, 1);

            Schedule(checkAnim);
        }
        public void loadGenericInfoFromDictionary(PlistDictionary dict, CCNode nd)
        {
            b2WorldDirty = false;
            _node        = nd;

            if (null != dict)
            {
                name = dict ["name"].AsString;
                uuid = dict ["uuid"].AsString;

                //tags loading
//				{
//					NSArray* loadedTags = [dict objectForKey:@"tags"];
//					if(loadedTags){
//						_tags = [[NSMutableArray alloc] initWithArray:loadedTags];
//					}
//				}

                //user properties loading
//				{
//					NSDictionary* userPropInfo  = [dict objectForKey:@"userPropertyInfo"];
//					NSString* userPropClassName = [dict objectForKey:@"userPropertyName"];
//					if(userPropInfo && userPropClassName)
//					{
//						Class userPropClass = NSClassFromString(userPropClassName);
//						if(userPropClass){
//							#pragma clang diagnostic push
//							#pragma clang diagnostic ignored "-Wundeclared-selector"
//							_userProperty = [userPropClass performSelector:@selector(customClassInstanceWithNode:)
//								withObject:_node];
//							#pragma clang diagnostic pop
//							if(_userProperty){
//								[_userProperty setPropertiesFromDictionary:userPropInfo];
//							}
//						}
//					}
//				}

                if (dict.ContainsKey("alpha"))
                {
                    _node.Opacity = (byte)dict ["alpha"].AsFloat;
                }

                if (dict.ContainsKey("rotation"))
                {
                    _node.Rotation = -dict ["rotation"].AsFloat;
                }

                if (dict.ContainsKey("zOrder"))
                {
                    _node.ZOrder = dict ["zOrder"].AsInt;
                }

                if (dict.ContainsKey("scale"))
                {
                    CCPoint scl = CCPoint.Parse(dict ["scale"].AsString);
                    _node.ScaleX = scl.X;
                    _node.ScaleY = scl.Y;
                }

                //for sprites the content size is set from the CCSpriteFrame
                if (dict.ContainsKey("size") && _node.GetType() != typeof(LHSprite))
                {
                    _node.ContentSize = CCSize.Parse(dict ["size"].AsString);
                }

                if (dict.ContainsKey("generalPosition")
                    &&
                    _node.GetType() != typeof(LHUINode)
                    &&
                    _node.GetType() != typeof(LHBackUINode)
                    &&
                    _node.GetType() != typeof(LHGameWorldNode))
                {
                    CCPoint unitPos = CCPoint.Parse(dict ["generalPosition"].AsString);
                    CCPoint pos     = LHUtils.positionForNode(_node, unitPos);

                    _node.Position = pos;
                }
//				if([dict objectForKey:@"generalPosition"]&&
//					![_node isKindOfClass:[LHUINode class]] &&
//					![_node isKindOfClass:[LHBackUINode class]] &&
//					![_node isKindOfClass:[LHGameWorldNode class]])
//				{
//
//					CGPoint unitPos = [dict pointForKey:@"generalPosition"];
//					CGPoint pos = [LHUtils positionForNode:_node
//						fromUnit:unitPos];
//
//					NSDictionary* devPositions = [dict objectForKey:@"devicePositions"];
//					if(devPositions)
//					{
//
//						NSString* unitPosStr = [LHUtils devicePosition:devPositions
//							forSize:LH_SCREEN_RESOLUTION];
//
//						if(unitPosStr){
//							CGPoint unitPos = LHPointFromString(unitPosStr);
//							pos = [LHUtils positionForNode:_node
//								fromUnit:unitPos];
//						}
//					}
//
//					[_node setPosition:pos];
//				}

//				if([dict objectForKey:@"anchor"] &&
//					![_node isKindOfClass:[LHUINode class]] &&
//					![_node isKindOfClass:[LHBackUINode class]] &&
//					![_node isKindOfClass:[LHGameWorldNode class]])
//				{
//					CGPoint anchor = [dict pointForKey:@"anchor"];
//					anchor.y = 1.0f - anchor.y;
//					[_node setAnchorPoint:anchor];
//				}
            }
        }
Example #42
0
 public override void StartWithTarget(CCNode target)
 {
     base.StartWithTarget(target);
     m_pOther.StartWithTarget(m_pTarget);
 }
Example #43
0
 public CCSplitRowsState(CCSplitRows action, CCNode target) : base(action, target)
 {
     VisibleBounds = Target.Layer.VisibleBoundsWorldspace;
 }
Example #44
0
 public override void StartWithTarget(CCNode target)
 {
     base.StartWithTarget(target);
     m_fDeltaX = m_fStartScaleX * m_fEndScaleX - m_fStartScaleX;
     m_fDeltaY = m_fStartScaleY * m_fEndScaleY - m_fStartScaleY;
 }
Example #45
0
 public override void startWithTarget(CCNode target)
 {
     base.startWithTarget(target);
     m_fStartAngle = target.rotation;
 }
 protected internal override CCActionState StartAction(CCNode target)
 {
     return(new CCCardinalSplineToState(this, target));
 }
Example #47
0
 public CCFlipY3DState(CCFlipY3D action, CCNode target) : base(action, target)
 {
 }
 public CCCardinalSplineByState(CCCardinalSplineTo action, CCNode target)
     : base(action, target)
 {
     StartPosition = target.Position;
 }
Example #49
0
        public virtual void AfterDraw(CCNode target)
        {
            Grabber.AfterRender(Texture);

            Scene.Window.DrawManager.BindTexture(Texture);
        }
Example #50
0
 protected override CCActionState StartAction(CCNode target)
 {
     return(new CCRotateAroundToState(this, target));
 }
Example #51
0
 protected internal override CCActionState StartAction(CCNode target)
 {
     return(new CCFlipX3DState(this, GridNode(target)));
 }
Example #52
0
 public Button(CCSprite sprite)
     : this()
 {
     child = sprite;
     AddChild(sprite);
 }
 protected internal override CCActionState StartAction(CCNode target)
 {
     return(new CCEaseExponentialInState(this, target));
 }
        public static CCNode createLHNodeWithDictionary(PlistDictionary childInfo, CCNode prnt)
        {
            string nodeType = childInfo["nodeType"].AsString;

            LHScene scene = ((LHNodeProtocol)prnt).getScene();

            string subclassNodeType = childInfo["subclassNodeType"].AsString;

            if (subclassNodeType != null && subclassNodeType.Length > 0)
            {
                //TODO handle subclasses

                //this will not work as we do not have the class included in the api
//				Class classObj = [scene createNodeObjectForSubclassWithName:subclassNodeType superTypeName:nodeType];
//				if(classObj){
//					return [classObj nodeWithDictionary:childInfo parent:prnt];
//				}
//				else{
//					NSLog(@"\n\nWARNING: Expected a class of type %@ subclassed from %@, but nothing was returned. Check your \"createNodeObjectForSubclassWithName:superTypeName:\" method and make sure you return a valid Class.\n\n", subclassNodeType, nodeType);
//				}
            }

            if (nodeType == "LHGameWorldNode")
            {
                LHGameWorldNode pNode = LHGameWorldNode.nodeWithDictionary(childInfo, prnt);
                pNode.ContentSize = scene._designResolutionSize;
//				#if LH_DEBUG
//				[pNode setDebugDraw:YES];
//				#endif
                return(pNode);
            }
            else if (nodeType == "LHBackUINode")
            {
                LHBackUINode pNode = LHBackUINode.nodeWithDictionary(childInfo, prnt);
                return(pNode);
            }
            else if (nodeType == "LHUINode")
            {
                LHUINode pNode = LHUINode.nodeWithDictionary(childInfo, prnt);
                return(pNode);
            }
            else if (nodeType == "LHSprite")
            {
                LHSprite spr = LHSprite.nodeWithDictionary(childInfo, prnt);
                return(spr);
            }
//			else if([nodeType isEqualToString:@"LHNode"])
//			{
//				LHNode* nd = [LHNode nodeWithDictionary:childInfo
//					parent:prnt];
//				return nd;
//			}
//			else if([nodeType isEqualToString:@"LHBezier"])
//			{
//				LHBezier* bez = [LHBezier nodeWithDictionary:childInfo
//					parent:prnt];
//				return bez;
//			}
//			else if([nodeType isEqualToString:@"LHTexturedShape"])
//			{
//				LHShape* sp = [LHShape nodeWithDictionary:childInfo
//					parent:prnt];
//				return sp;
//			}
//			else if([nodeType isEqualToString:@"LHWaves"])
//			{
//				LHWater* wt = [LHWater nodeWithDictionary:childInfo
//					parent:prnt];
//				return wt;
//			}
//			else if([nodeType isEqualToString:@"LHAreaGravity"])
//			{
//				LHGravityArea* gv = [LHGravityArea nodeWithDictionary:childInfo
//					parent:prnt];
//				return gv;
//			}
//			else if([nodeType isEqualToString:@"LHParallax"])
//			{
//				LHParallax* pr = [LHParallax nodeWithDictionary:childInfo
//					parent:prnt];
//				return pr;
//			}
//			else if([nodeType isEqualToString:@"LHParallaxLayer"])
//			{
//				LHParallaxLayer* lh = [LHParallaxLayer nodeWithDictionary:childInfo
//					parent:prnt];
//				return lh;
//			}
//			else if([nodeType isEqualToString:@"LHAsset"])
//			{
//				LHAsset* as = [LHAsset nodeWithDictionary:childInfo
//					parent:prnt];
//				return as;
//			}
//			else if([nodeType isEqualToString:@"LHCamera"])
//			{
//				LHCamera* cm = [LHCamera nodeWithDictionary:childInfo
//					parent:prnt];
//				return cm;
//			}
//			else if([nodeType isEqualToString:@"LHRopeJoint"])
//			{
//				LHRopeJointNode* jt = [LHRopeJointNode nodeWithDictionary:childInfo
//					parent:prnt];
//				return jt;
//			}
//			else if([nodeType isEqualToString:@"LHWeldJoint"])
//			{
//				LHWeldJointNode* jt = [LHWeldJointNode nodeWithDictionary:childInfo
//					parent:prnt];
//				return jt;
//			}
//			else if([nodeType isEqualToString:@"LHRevoluteJoint"]){
//
//				LHRevoluteJointNode* jt = [LHRevoluteJointNode nodeWithDictionary:childInfo
//					parent:prnt];
//				return jt;
//			}
//			else if([nodeType isEqualToString:@"LHDistanceJoint"]){
//
//				LHDistanceJointNode* jt = [LHDistanceJointNode nodeWithDictionary:childInfo
//					parent:prnt];
//				return jt;
//
//			}
//			else if([nodeType isEqualToString:@"LHPulleyJoint"]){
//
//				LHPulleyJointNode* jt = [LHPulleyJointNode nodeWithDictionary:childInfo
//					parent:prnt];
//				return jt;
//			}
//			else if([nodeType isEqualToString:@"LHPrismaticJoint"]){
//
//				LHPrismaticJointNode* jt = [LHPrismaticJointNode nodeWithDictionary:childInfo
//					parent:prnt];
//				return jt;
//			}
//			else if([nodeType isEqualToString:@"LHWheelJoint"]){
//
//				LHWheelJointNode* jt = [LHWheelJointNode nodeWithDictionary:childInfo
//					parent:prnt];
//				return jt;
//			}
//			else if([nodeType isEqualToString:@"LHGearJoint"]){
//
//				LHGearJointNode* jt = [LHGearJointNode nodeWithDictionary:childInfo
//					parent:prnt];
//				return jt;
//			}
//
//
//			else{
//				NSLog(@"UNKNOWN NODE TYPE %@", nodeType);
//			}

            return(null);
        }
Example #55
0
        private void HandleMoveCircle(CCTouch touch)
        {
            const float        timeToTake = 1.5f;      // in seconds
            CCFiniteTimeAction coreAction = null;

            // By default all actions will be added directly to the
            // root node - it has values for Position, Scale, and Rotation.
            CCNode nodeToAddTo = drawNodeRoot;

            switch (VariableOptions [currentVariableIndex])
            {
            case "Position":
                coreAction = new CCMoveTo(timeToTake, touch.Location);

                break;

            case "Scale":
                var distance     = CCPoint.Distance(touch.Location, drawNodeRoot.Position);
                var desiredScale = distance / DefaultCircleRadius;
                coreAction = new CCScaleTo(timeToTake, desiredScale);

                break;

            case "Rotation":
                float differenceY = touch.Location.Y - drawNodeRoot.PositionY;
                float differenceX = touch.Location.X - drawNodeRoot.PositionX;

                float angleInDegrees = -1 * CCMathHelper.ToDegrees(
                    (float)System.Math.Atan2(differenceY, differenceX));

                coreAction = new CCRotateTo(timeToTake, angleInDegrees);

                break;

            case "LineWidth":
                coreAction = new LineWidthAction(timeToTake, touch.Location.X / 40.0f);
                // The LineWidthAction is a special action designed to work only on
                // LineNode instances, so we have to set the nodeToAddTo to the lineNode:
                nodeToAddTo = lineNode;
                break;
            }

            CCAction easing = null;

            switch (EasingOptions [currentEasingIndex])
            {
            case "<None>":
                // no easing, do nothing. We'll add the coreAction
                // instead of easing
                break;

            case "CCEaseBack":
                if (currentInOutIndex == 0)
                {
                    easing = new CCEaseBackOut(coreAction);
                }
                else if (currentInOutIndex == 1)
                {
                    easing = new CCEaseBackIn(coreAction);
                }
                else
                {
                    easing = new CCEaseBackInOut(coreAction);
                }

                break;

            case "CCEaseBounce":
                if (currentInOutIndex == 0)
                {
                    easing = new CCEaseBounceOut(coreAction);
                }
                else if (currentInOutIndex == 1)
                {
                    easing = new CCEaseBounceIn(coreAction);
                }
                else
                {
                    easing = new CCEaseBounceInOut(coreAction);
                }

                break;

            case "CCEaseElastic":
                if (currentInOutIndex == 0)
                {
                    easing = new CCEaseElasticOut(coreAction);
                }
                else if (currentInOutIndex == 1)
                {
                    easing = new CCEaseElasticIn(coreAction);
                }
                else
                {
                    easing = new CCEaseElasticInOut(coreAction);
                }

                break;

            case "CCEaseExponential":
                if (currentInOutIndex == 0)
                {
                    easing = new CCEaseExponentialOut(coreAction);
                }
                else if (currentInOutIndex == 1)
                {
                    easing = new CCEaseExponentialIn(coreAction);
                }
                else
                {
                    easing = new CCEaseExponentialInOut(coreAction);
                }

                break;

            case "CCEaseSine":

                if (currentInOutIndex == 0)
                {
                    easing = new CCEaseSineOut(coreAction);
                }
                else if (currentInOutIndex == 1)
                {
                    easing = new CCEaseSineIn(coreAction);
                }
                else
                {
                    easing = new CCEaseSineInOut(coreAction);
                }

                break;
            }

            if (easing != null)
            {
                nodeToAddTo.AddAction(easing);
            }
            else
            {
                nodeToAddTo.AddAction(coreAction);
            }
        }
 public CCEaseExponentialInState(CCEaseExponentialIn action, CCNode target) : base(action, target)
 {
 }
Example #57
0
        public void initWithSubTest(int nSubTest, CCNode p)
        {
            subtestNumber = nSubTest;
            parent        = p;
            batchNode     = null;

            /*
             * Tests:
             * 1: 1 (32-bit) PNG sprite of 52 x 139
             * 2: 1 (32-bit) PNG Batch Node using 1 sprite of 52 x 139
             * 3: 1 (16-bit) PNG Batch Node using 1 sprite of 52 x 139
             * 4: 1 (4-bit) PVRTC Batch Node using 1 sprite of 52 x 139
             *
             * 5: 14 (32-bit) PNG sprites of 85 x 121 each
             * 6: 14 (32-bit) PNG Batch Node of 85 x 121 each
             * 7: 14 (16-bit) PNG Batch Node of 85 x 121 each
             * 8: 14 (4-bit) PVRTC Batch Node of 85 x 121 each
             *
             * 9: 64 (32-bit) sprites of 32 x 32 each
             * 10: 64 (32-bit) PNG Batch Node of 32 x 32 each
             * 11: 64 (16-bit) PNG Batch Node of 32 x 32 each
             * 12: 64 (4-bit) PVRTC Batch Node of 32 x 32 each
             */

            // purge textures
            CCTextureCache mgr = CCTextureCache.SharedTextureCache;

            mgr.RemoveTexture(mgr.AddImage("Images/grossinis_sister1"));
            mgr.RemoveTexture(mgr.AddImage("Images/grossini_dance_atlas"));
            mgr.RemoveTexture(mgr.AddImage("Images/spritesheet1"));

            switch (subtestNumber)
            {
            case 1:
            case 4:
            case 7:
                break;

            case 2:
                CCTexture2D.DefaultAlphaPixelFormat = SurfaceFormat.Color;
                batchNode = new CCSpriteBatchNode("Images/grossinis_sister1", 100);
                p.AddChild(batchNode, 0);
                break;

            case 3:
                CCTexture2D.DefaultAlphaPixelFormat = SurfaceFormat.Bgra4444;
                batchNode = new CCSpriteBatchNode("Images/grossinis_sister1", 100);
                p.AddChild(batchNode, 0);
                break;

            case 5:
                CCTexture2D.DefaultAlphaPixelFormat = SurfaceFormat.Color;
                batchNode = new CCSpriteBatchNode("Images/grossini_dance_atlas", 100);
                p.AddChild(batchNode, 0);
                break;

            case 6:
                CCTexture2D.DefaultAlphaPixelFormat = SurfaceFormat.Bgra4444;
                batchNode = new CCSpriteBatchNode("Images/grossini_dance_atlas", 100);
                p.AddChild(batchNode, 0);
                break;

            ///
            case 8:
                CCTexture2D.DefaultAlphaPixelFormat = SurfaceFormat.Color;
                batchNode = new CCSpriteBatchNode("Images/spritesheet1", 100);
                p.AddChild(batchNode, 0);
                break;

            case 9:
                CCTexture2D.DefaultAlphaPixelFormat = SurfaceFormat.Bgra4444;
                batchNode = new CCSpriteBatchNode("Images/spritesheet1", 100);
                p.AddChild(batchNode, 0);
                break;

            default:
                break;
            }

            //if (batchNode != null)
            //{
            //    batchNode.retain();
            //}

            CCTexture2D.DefaultAlphaPixelFormat = SurfaceFormat.Color;
        }
Example #58
0
 public CCTiledGrid3DActionState(CCTiledGrid3DAction action, CCNode target) : base(action, target)
 {
 }
Example #59
0
 public CCPlaceState(CCPlace action, CCNode target)
     : base(action, target)
 {
     Target.Position = action.Position;
 }
Example #60
0
 protected override CCActionState StartAction(CCNode target)
 {
     return(new LineWidthState(this, target, endWidth));
 }