• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# CCNode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中CCNode的典型用法代码示例。如果您正苦于以下问题:C# CCNode类的具体用法?C# CCNode怎么用?C# CCNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CCNode类属于命名空间,在下文中一共展示了CCNode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: StartWithTarget

        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;
            }
        }
开发者ID:eickegao,项目名称:cocos2d-xna,代码行数:26,代码来源:CCRotateTo.cs


示例2: OnEnter

        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);
        }
开发者ID:haithemaraissia,项目名称:CocosSharp,代码行数:60,代码来源:CCControlButtonTest.cs


示例3: StartWithTarget

 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);
 }
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:7,代码来源:CCBezierTo.cs


示例4: CCTileMap

        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++;
                    }
                }
            }
        }
开发者ID:KevinHeyer,项目名称:CocosSharp,代码行数:35,代码来源:CCTileMap.cs


示例5: SpriteZVertex

        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;
            }
        }
开发者ID:netonjm,项目名称:CocosSharp,代码行数:32,代码来源:SpriteZVertex.cs


示例6: StressIt

        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 ();
        }
开发者ID:KevinHeyer,项目名称:CocosSharp,代码行数:29,代码来源:LabelSystemFont168.cs


示例7: StartWithTarget

 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);
 }
开发者ID:homocury,项目名称:cocos2d-xna,代码行数:7,代码来源:CCBezierTo.cs


示例8: CreateLabel

        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;
        }
开发者ID:KevinHeyer,项目名称:CocosSharp,代码行数:33,代码来源:LabelSystemFont168.cs


示例9: NodeToWorld3D

		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);
		}
开发者ID:h7ing,项目名称:CocosSharp,代码行数:28,代码来源:NodeToWorld.cs


示例10: AddedToScene

        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;
            }
        }
开发者ID:h7ing,项目名称:CocosSharp,代码行数:32,代码来源:SpriteZVertex.cs


示例11: CCGridActionState

		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;
			}
		}
开发者ID:h7ing,项目名称:CocosSharp,代码行数:31,代码来源:CCGridAction.cs


示例12: CCFiniteTimeActionState

 public CCFiniteTimeActionState (CCFiniteTimeAction action, CCNode target)
     : base (action, target)
 { 
     Duration = action.Duration;
     Elapsed = 0.0f;
     firstTick = true;
 }
开发者ID:h7ing,项目名称:CocosSharp,代码行数:7,代码来源:CCFiniteTimeAction.cs


示例13: CCShuffleTilesState

        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++;
                }
            }
        }
开发者ID:KerwinMa,项目名称:CocosSharp,代码行数:33,代码来源:CCShuffleTiles.cs


示例14: CCLens3DState

 public CCLens3DState (CCLens3D action, CCNode target) : base (action, target)
 {
     Position = action.Position;
     Radius = action.Radius;
     LensScale = action.LensScale;
     Concave = action.Concave;
 }
开发者ID:KerwinMa,项目名称:CocosSharp,代码行数:7,代码来源:CCLens3D.cs


示例15: CCRotateAroundToState

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


        }
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:29,代码来源:RotateAroundActions.cs


示例16: OnEnter

        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);
        }
开发者ID:KerwinMa,项目名称:CocosSharp,代码行数:29,代码来源:Issue631.cs


示例17: OnHandlePropTypeCheck

 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);
     }
 }
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:26,代码来源:CCLayerLoader.cs


示例18: GetActionState

        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;
        }
开发者ID:h7ing,项目名称:CocosSharp,代码行数:32,代码来源:CCActionManager.cs


示例19: StartWithTarget

 public override void StartWithTarget(CCNode target)
 {
     m_uTotal = 0;
     m_fNextDt = m_pInnerAction.Duration / m_fDuration;
     base.StartWithTarget(target);
     m_pInnerAction.StartWithTarget(target);
 }
开发者ID:pekayatt,项目名称:cocos2d-xna,代码行数:7,代码来源:CCRepeat.cs


示例20: startWithTarget

 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);
 }
开发者ID:Ratel13,项目名称:cocos2d-x-for-xna,代码行数:7,代码来源:CCBezierTo.cs



注:本文中的CCNode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CCPoint类代码示例发布时间:2022-05-24
下一篇:
C# CCEvent类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap