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

C# CCRect类代码示例

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

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



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

示例1: FromAnimationSave

        public static Animation FromAnimationSave(AnimationChainSave animationSave)
        {
            //这个类没有构造函数,所以编译器自动会添加一个空的构造函数
            Animation toReturn = new Animation ();

            toReturn.Name = animationSave.Name;

            //读取frame(AnimationFrameSave)中的所有动画数据
            foreach (var frame in animationSave.Frames)
            {
                CCRect rectangle;

                rectangle = new CCRect (
                    frame.LeftCoordinate,
                    frame.TopCoordinate,
                    frame.RightCoordinate - frame.LeftCoordinate,
                    frame.BottomCoordinate - frame.TopCoordinate);

                var duration = TimeSpan.FromSeconds (frame.FrameLength);

                //toReturn.frames是一个frame的集合
                //每一个frame是动作的一步
                //AddFrame就是把读取到的frame添加到这个list里
                toReturn.AddFrame (rectangle, duration, flipHorizontal:frame.FlipHorizontal);
            }

            return toReturn;
        }
开发者ID:coroner4817,项目名称:CoinTime,代码行数:28,代码来源:Animation.cs


示例2: CCFollow

        public CCFollow(Node followedNode, CCRect rect)
        {
            Debug.Assert(followedNode != null);

            this._followedNode = followedNode;
            this._isBoundaryFullyCovered = false;
            this.IsBoundarySet = true;

            CCSize winSize = Director.SharedDirector.DesignSize;
            this._fullScreenSize = new CCPoint(winSize.Width, winSize.Height);
            this._halfScreenSize = this._fullScreenSize * 0.5f;

            this._leftBoundary = -((rect.Origin.X + rect.Size.Width) - this._fullScreenSize.X);
            this._rightBoundary = -rect.Origin.X;
            this._topBoundary = -rect.Origin.Y;
            this._bottomBoundary = -((rect.Origin.Y + rect.Size.Height) - this._fullScreenSize.Y);

            if (this._rightBoundary < this._leftBoundary)
            {
                //screen width is larger than world's boundary width set both in the middle of the world
                this._rightBoundary = this._leftBoundary = (this._leftBoundary + this._rightBoundary) / 2;
            }
            if (this._topBoundary < this._bottomBoundary)
            {
                //screen width is larger than world's boundary width set both in the middle of the world
                this._topBoundary = this._bottomBoundary = (this._topBoundary + this._bottomBoundary) / 2;
            }

            if ((this._topBoundary == this._bottomBoundary) && (this._leftBoundary == this._rightBoundary))
            {
                this._isBoundaryFullyCovered = true;
            }
        }
开发者ID:liwq-net,项目名称:liwq,代码行数:33,代码来源:CCFollow.cs


示例3: ApplicationDidFinishLaunching

        public override void ApplicationDidFinishLaunching(CCApplication application, CCWindow mainWindow)
        {
            //application.SupportedOrientations = CCDisplayOrientation.LandscapeRight | CCDisplayOrientation.LandscapeLeft;
            //application.AllowUserResizing = true;
            //application.PreferMultiSampling = false;
            application.ContentRootDirectory = "Content";


            CCRect boundsRect = new CCRect(0.0f, 0.0f, 960, 640);

			sharedViewport = new CCViewport(new CCRect (0.0f, 0.0f, 1.0f, 1.0f));

            sharedWindow = mainWindow;
            sharedCamera = new CCCamera(boundsRect.Size, new CCPoint3(boundsRect.Center, 100.0f), new CCPoint3(boundsRect.Center, 0.0f));

            mainWindow.SetDesignResolutionSize(960, 640, CCSceneResolutionPolicy.ShowAll);

            #if WINDOWS || WINDOWSGL || WINDOWSDX 
			//application.PreferredBackBufferWidth = 1024;
			//application.PreferredBackBufferHeight = 768;
            #elif MACOS
            //application.PreferredBackBufferWidth = 960;
            //application.PreferredBackBufferHeight = 640;
            #endif

            #if WINDOWS_PHONE8
            application.HandleMediaStateAutomatically = false; // Bug in MonoGame - https://github.com/Cocos2DXNA/cocos2d-xna/issues/325
            #endif

            CCSpriteFontCache.FontScale = 0.6f;
            CCSpriteFontCache.RegisterFont("arial", 12, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 38, 50, 64);
            CCSpriteFontCache.RegisterFont("MarkerFelt", 16, 18, 22, 32);
            CCSpriteFontCache.RegisterFont("MarkerFelt-Thin", 12, 18);
            CCSpriteFontCache.RegisterFont("Paint Boy", 26);
            CCSpriteFontCache.RegisterFont("Schwarzwald Regular", 26);
            CCSpriteFontCache.RegisterFont("Scissor Cuts", 26);
            CCSpriteFontCache.RegisterFont("A Damn Mess", 26);
            CCSpriteFontCache.RegisterFont("Abberancy", 26);
            CCSpriteFontCache.RegisterFont("Abduction", 26);

            //sharedDirector = new CCDirector();
            //director.DisplayStats = true;
            //director.AnimationInterval = 1.0 / 60;


//            if (sharedWindow.WindowSizeInPixels.Height > 320)
//            {
//                application.ContentSearchPaths.Insert(0,"HD");
//            }

            //sharedWindow.AddSceneDirector(sharedDirector);

            CCScene scene = new CCScene(sharedWindow);
			scene.Camera = sharedCamera;

            CCLayer layer = new TestController();

            scene.AddChild(layer);
            sharedWindow.RunWithScene(scene);
        }
开发者ID:netonjm,项目名称:CocosSharp,代码行数:60,代码来源:AppDelegate.cs


示例4: CreateHowtoLabel

		private void CreateHowtoLabel()
		{
			float backgroundWidth = howToImage.ScaledContentSize.Width;
			const float backgroundHeight = 36;

			labelBackground = new CCDrawNode ();

			var rect = new CCRect (
				-backgroundWidth / 2.0f, -backgroundHeight / 2.0f, 
				backgroundWidth , backgroundHeight );
			labelBackground.DrawRect (
				rect, CCColor4B.Black);
			labelBackground.PositionX = ContentSize.Center.X;
			labelBackground.PositionY = 74;
			mainLayer.AddChild (labelBackground);


			howToLabel = new CCLabel(
				"Touch and move on the left side of the screen to move.\nTap on the right side to jump.", 
				"fonts/Aldrich-Regular.ttf", 12, CCLabelFormat.SystemFont);
			howToLabel.PositionX = ContentSize.Center.X;
			howToLabel.Scale = .5f;
			howToLabel.PositionY = 74;
			howToLabel.HorizontalAlignment = CCTextAlignment.Center;
			howToLabel.VerticalAlignment = CCVerticalTextAlignment.Center;
			howToLabel.IsAntialiased = false;

			mainLayer.AddChild (howToLabel);
		}
开发者ID:xamarin,项目名称:mobile-samples,代码行数:29,代码来源:HowToPlayScene.cs


示例5: BallPaddleRectIntersects

 public bool BallPaddleRectIntersects(CCRect r1, CCRect r2)
 {
     if (r1.MinY < r2.MaxY) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:coroner4817,项目名称:MyBouncingGame,代码行数:8,代码来源:PhysicsEntity.cs


示例6: CCSpriteFrame

 public CCSpriteFrame(CCSize contentSize, CCTexture2D texture, CCRect textureRectInPxls, 
     CCSize originalSizeInPxls, bool rotated=false, CCPoint? offsetInPxls=null)
 {
     TextureRectInPixels = textureRectInPxls;
     ContentSize = contentSize;
     OffsetInPixels = offsetInPxls ?? CCPoint.Zero;
     OriginalSizeInPixels = originalSizeInPxls;
     IsRotated = rotated;
     Texture = texture;
 }
开发者ID:h7ing,项目名称:CocosSharp,代码行数:10,代码来源:CCSpriteFrame.cs


示例7: RectForGID

        public CCSize TileSize { get; set; }            // The size of this tile in unscaled pixels

        #endregion Properties

        public CCRect RectForGID(uint gid)
        {
            CCRect rect = new CCRect();
            rect.Size = TileSize;
            gid &= CCTMXTileFlags.FlippedMask;
            gid = gid - FirstGid;
            var max_x = (int) ((ImageSize.Width - Margin * 2 + Spacing) / (TileSize.Width + Spacing));
            rect.Origin.X = (gid % max_x) * (TileSize.Width + Spacing) + Margin;
            rect.Origin.Y = (gid / max_x) * (TileSize.Height + Spacing) + Margin;
            return rect;
        }
开发者ID:h7ing,项目名称:CocosSharp,代码行数:15,代码来源:CCTMXTilesetInfo.cs


示例8: RectForGID

 public CCRect RectForGID(uint gid)
 {
     CCRect rect = new CCRect();
     rect.Size = m_tTileSize;
     gid &= ccTMXTileFlags.kCCFlippedMask;
     gid = gid - m_uFirstGid;
     var max_x = (int) ((m_tImageSize.Width - m_uMargin * 2 + m_uSpacing) / (m_tTileSize.Width + m_uSpacing));
     //	int max_y = (imageSize.height - margin*2 + spacing) / (tileSize.height + spacing);
     rect.Origin.X = (gid % max_x) * (m_tTileSize.Width + m_uSpacing) + m_uMargin;
     rect.Origin.Y = (gid / max_x) * (m_tTileSize.Height + m_uSpacing) + m_uMargin;
     return rect;
 }
开发者ID:eickegao,项目名称:cocos2d-xna,代码行数:12,代码来源:CCTMXTilesetInfo.cs


示例9: CCDrawNode

        public CCDrawNode()
        {
            renderTriangles = new CCCustomCommand(FlushTriangles);
            renderLines = new CCCustomCommand(FlushLines);
            renderStrings = new CCCustomCommand(DrawStrings);

            BlendFunc = CCBlendFunc.AlphaBlend;
            triangleVertices = new CCRawList<CCV3F_C4B>(DefaultBufferSize);
            lineVertices = new CCRawList<CCV3F_C4B>(DefaultBufferSize);

            verticeBounds = CCRect.Zero;
        }
开发者ID:luiseduardohdbackup,项目名称:CocosSharp,代码行数:12,代码来源:CCDrawNode.cs


示例10: Initialize

            public void Initialize(CCRect bounds, float mag)
            {
                ColorPen = new Pen(new Microsoft.Xna.Framework.Color(rand.Next(255), rand.Next(255), rand.Next(255)));

                for (int i = 0; i < Points.Length; i++)
                {
                    Points[i] = new CCVector2(bounds.MinX + (float)rand.NextDouble() * bounds.Size.Width, bounds.MaxY + (float)rand.NextDouble() * bounds.Size.Height);
                    Velocities[i] = new CCVector2((float)(rand.NextDouble() - .5) * mag, (float)(rand.NextDouble() - .5) * mag);

                    for (int j = 0; j < History.Count; j++)
                        History[j][i] = Points[i];
                }
            }
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:13,代码来源:Mystify.cs


示例11: SneakyButtonControl

 public SneakyButtonControl(CCRect rect, int id, CCDrawNode drawNode )
 {
     this.drawNode = drawNode;
     status = true; //defaults to enabled
     value = false;
     active = false;
     isHoldable = true;
     isToggleable = false;
     radius = 32.0f;
     rateLimit = 1.0f / 120.0f;
     Position = rect.Origin;
     ID = id;
     buttonEvent = new CCEventCustom(SneakyPanelControl.BUTTON_LISTENER_ID);
 }
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:14,代码来源:SneakyButtonControl.cs


示例12: TextureRectForGID

        public CCRect TextureRectForGID(short gid)
        {
            CCRect rect = new CCRect();

            if (gid != 0)
            {
                // Rect offset relative to first gid
                gid -= FirstGid;
                rect.Size = TileTexelSize;
                var max_x = (int)((TilesheetSize.Width - BorderWidth * 2 + TileSpacing) / (TileTexelSize.Width + TileSpacing));
                rect.Origin.X = (gid % max_x) * (TileTexelSize.Width + TileSpacing) + BorderWidth;
                rect.Origin.Y = (gid / max_x) * (TileTexelSize.Height + TileSpacing) + BorderWidth;
            }
            return rect;
        }
开发者ID:AnimaRobotics,项目名称:CocosSharp,代码行数:15,代码来源:CCTileSetInfo.cs


示例13: CCFollow

        public CCFollow(CCNode followedNode, CCRect rect)
        {
            Debug.Assert (followedNode != null);

            FollowedNode = followedNode;
            if (rect.Equals (CCRect.Zero))
            {
                UsingBoundary = false;
            }
            else
            {
                UsingBoundary = true;
            }

            BoundaryFullyCovered = false;

            CCRect viewportBounds = followedNode.Layer.VisibleBoundsWorldspace;
            FullScreenSize = (CCPoint)new CCPoint(viewportBounds.Size.Width, viewportBounds.Size.Height);
            HalfScreenSize = FullScreenSize * 0.5f;

            if (UsingBoundary)
            {
                float leftBoundary = -((rect.Origin.X + rect.Size.Width) - FullScreenSize.X - viewportBounds.Origin.X);
                float rightBoundary = -rect.Origin.X;
                float topBoundary = -rect.Origin.Y;
                float bottomBoundary = -((rect.Origin.Y + rect.Size.Height) - FullScreenSize.Y - viewportBounds.Origin.Y);

                if (rightBoundary < leftBoundary)
                {
                    // screen width is larger than world's boundary width
                    //set both in the middle of the world
                    rightBoundary = leftBoundary = (leftBoundary + rightBoundary) / 2;
                }
                if (topBoundary < bottomBoundary)
                {
                    // screen width is larger than world's boundary width
                    //set both in the middle of the world
                    topBoundary = bottomBoundary = (topBoundary + bottomBoundary) / 2;
                }

                if ((topBoundary == bottomBoundary) && (leftBoundary == rightBoundary))
                {
                    BoundaryFullyCovered = true;
                }

                Boundary = new CCFollowBoundary (bottomBoundary, leftBoundary, rightBoundary, topBoundary);
            }
        }
开发者ID:KerwinMa,项目名称:CocosSharp,代码行数:48,代码来源:CCFollow.cs


示例14: OnTouchEnded

 public void OnTouchEnded(CCTouch touch, CCEvent e)
 {
     if (Enable)
     {
         foreach (var control in ControlList)
         {
             var p = control.PositionWorldspace;
             var rect = new CCRect(p.X, p.Y, control.ContentSize.Width, control.ContentSize.Height);
             if (rect.ContainsPoint(Target.Layer.ScreenToWorldspace(touch.LocationOnScreen)))
             {
                 control.OnTouchEnded(touch, e);
                 return;
             }
         }
     }
 }
开发者ID:xxy1991,项目名称:cozy,代码行数:16,代码来源:ButtonEventDispatcher.cs


示例15: SneakyJoystickControl

        public SneakyJoystickControl(CCRect rect)
            : base()
        {
            Degrees = 0.0f;
            Velocity = CCPoint.Zero;
            AutoCenter = true;

            HasDeadzone = false;
            NumberOfDirections = 4;

            isDPad = false;
            joystickRadius = rect.Size.Width / 2;

            ThumbRadius = 32.0f;
            DeadRadius = 0.0f;

            AnchorPoint = CCPoint.AnchorMiddle;

            ControlSize = rect;
        }
开发者ID:KerwinMa,项目名称:cocos-sharp-samples,代码行数:20,代码来源:SneakyJoystickControl.cs


示例16: InitCloud

        void InitCloud()
        {

            CCRect rect;
            switch (ran.Next() % 3)
            {
                case 0:
                    rect = new CCRect(336, 16, 256, 108);
                    break;
                case 1:
                    rect = new CCRect(336, 128, 257, 110);
                    break;
                default:
                    rect = new CCRect(336, 240, 252, 119);
                    break;
            }

            var batchNode = GetChildByTag((int)Tags.SpriteManager) as CCSpriteBatchNode;
            var cloud = new CCSprite(batchNode.Texture, rect);
            batchNode.AddChild(cloud, 3, currentCloudTag);

            cloud.Opacity = 128;
        }
开发者ID:KerwinMa,项目名称:CocosSharp,代码行数:23,代码来源:MainLayer.cs


示例17: FromAnimationSave

		public static Animation FromAnimationSave(AnimationChainSave animationSave)
		{
			Animation toReturn = new Animation ();

			toReturn.Name = animationSave.Name;

			foreach (var frame in animationSave.Frames)
			{
				CCRect rectangle;

				rectangle = new CCRect (
					frame.LeftCoordinate, 
					frame.TopCoordinate, 
					frame.RightCoordinate - frame.LeftCoordinate, 
					frame.BottomCoordinate - frame.TopCoordinate);

				var duration = TimeSpan.FromSeconds (frame.FrameLength);

				toReturn.AddFrame (rectangle, duration, flipHorizontal:frame.FlipHorizontal);
			}

			return toReturn;
		}
开发者ID:ARMoir,项目名称:mobile-samples,代码行数:23,代码来源:Animation.cs


示例18: Update

            public void Update(CCRect bounds, float time)
            {
                for (int i = 0; i < Points.Length; i++)
                {
                    Points[i] += Velocities[i] * time;
                    if (Points[i].X < bounds.MinX)
                        Velocities[i].X = Math.Abs(Velocities[i].X);
                    else if (Points[i].X > bounds.MaxX)
                        Velocities[i].X = -Math.Abs(Velocities[i].X);
                    if (Points[i].Y < bounds.MaxY)
                        Velocities[i].Y = Math.Abs(Velocities[i].Y);
                    else if (Points[i].Y > bounds.MinY)
                        Velocities[i].Y = -Math.Abs(Velocities[i].Y);
                }

                Skip += time;
                if (Skip >= SkipLimit)
                {
                    Skip = 0;
                    for (int i = History.Count - 1; i > 0; i--)
                        History[i - 1].CopyTo(History[i], 0);
                    Points.CopyTo(History[0], 0);
                }
            }
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:24,代码来源:Mystify.cs


示例19: DrawRect

		public void DrawRect(CCRect rect, cpColor color)
		{
			base.DrawRect(rect, color.ToCCColor4B());
		}
开发者ID:h7ing,项目名称:CocosSharp,代码行数:4,代码来源:CCPhysicsDebugNode+.cs


示例20: GetSeparatingVector

        CCVector2 GetSeparatingVector(CCRect first, RectWithDirection second)
        {
            //返回一个向量,是player在碰撞之后反方向移动的向量

            // Default to no separation
            CCVector2 separation = CCVector2.Zero;

            // Only calculate separation if the rectangles intersect
            if (Intersects(first, second))
            {
                // The intersectionRect returns the rectangle produced
                // by overlapping the two rectangles.
                // This is protected by partitioning and deep collision, so it
                // won't happen too often - it's okay to do a ToRect here
                //得到两个rect重叠部分的rect
                var intersectionRect = first.Intersection (second.ToRect());

                float minDistance = float.PositiveInfinity;

                float firstCenterX = first.Center.X;
                float firstCenterY = first.Center.Y;

                float secondCenterX = second.Left + second.Width / 2.0f;
                float secondCenterY = second.Bottom + second.Width / 2.0f;

                //second的方向和想要判断的方向(左)取交集,如果和想要判断的方向(左)一致,且第一个的中心点在第二个的中心点的(左边)
                //则当碰撞时,player可以向想要的方向移动
                bool canMoveLeft = (second.Directions & Directions.Left) == Directions.Left && firstCenterX < secondCenterX;
                bool canMoveRight = (second.Directions & Directions.Right) == Directions.Right && firstCenterX > secondCenterX;
                bool canMoveDown = (second.Directions & Directions.Down) == Directions.Down && firstCenterY < secondCenterY;
                bool canMoveUp = (second.Directions & Directions.Up) == Directions.Up && firstCenterY > secondCenterY;

                if (canMoveLeft)
                {
                    //左重叠
                    //得到重叠的rect的X方向边长
                    float candidate = first.UpperRight.X - second.Left;

                    if (candidate > 0)
                    {
                        minDistance = candidate;

                        //x方向移动回到地图实体瓦片的外面,y方向不动
                        separation.X = -minDistance;
                        separation.Y = 0;
                    }
                }
                if (canMoveRight)
                {
                    //右重叠
                    float candidate = (second.Left + second.Width) - first.LowerLeft.X;

                    if (candidate > 0 && candidate < minDistance)
                    {
                        minDistance = candidate;

                        //向右移动
                        separation.X = minDistance;
                        separation.Y = 0;
                    }
                }
                //其他方向同理
                if (canMoveUp)
                {
                    float candidate = (second.Bottom + second.Height) - first.Origin.Y;

                    if (candidate > 0 && candidate < minDistance)
                    {
                        minDistance = candidate;

                        separation.X = 0;
                        separation.Y = minDistance;
                    }

                }
                if (canMoveDown)
                {
                    float candidate = first.UpperRight.Y - second.Bottom;

                    if (candidate > 0 && candidate < minDistance)
                    {
                        minDistance = candidate;

                        separation.X = 0;
                        separation.Y = -minDistance;
                    }
                }
            }

            //左后返回player移动的vector
            return separation;
        }
开发者ID:coroner4817,项目名称:CoinTime,代码行数:92,代码来源:LevelCollision.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# CCScene类代码示例发布时间:2022-05-24
下一篇:
C# CCPoint类代码示例发布时间: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