当前位置: 首页>>代码示例>>C#>>正文


C# CCRect类代码示例

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


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


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