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


C# CCSize类代码示例

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


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

示例1: GenerateGradient

        /*
         *  TL    TR
         *   0----1 0,1,2,3 = index offsets for vertex indices
         *   |   /|
         *   |  / |
         *   | /  |
         *   |/   |
         *   2----3
         *  BL    BR
         */
        void GenerateGradient(CCSize textureSizeInPixels)
        {
            var gradientNode = new CCDrawNode();

            var gradientAlpha = new CCColor4B(0, 0, 0,(byte)(0.7f * 255f));
            CCV3F_C4B[] vertices = new CCV3F_C4B[6];

            // Left triangle TL - 0
            vertices[0].Vertices = new CCVertex3F(0, textureSizeInPixels.Height, 0);
            vertices[0].Colors = CCColor4B.Transparent;

            // Left triangle BL - 2
            vertices[1].Vertices = new CCVertex3F(0, 0, 0);
            vertices[1].Colors = gradientAlpha;

            // Left triangle TR - 1
            vertices[2].Vertices = new CCVertex3F(textureSizeInPixels.Width, textureSizeInPixels.Height, 0);
            vertices[2].Colors = CCColor4B.Transparent;

            // Right triangle BL - 2
            vertices[3].Vertices = new CCVertex3F(0, 0, 0);
            vertices[3].Colors = gradientAlpha;

            // Right triangle BR - 3
            vertices[4].Vertices = new CCVertex3F(textureSizeInPixels.Width, 0, 0);
            vertices[4].Colors = gradientAlpha;

            // Right triangle TR - 1
            vertices[5].Vertices = new CCVertex3F(textureSizeInPixels.Width, textureSizeInPixels.Height, 0);
            vertices[5].Colors = CCColor4B.Transparent;

            gradientNode.DrawTriangleList(vertices);

            gradientNode.Visit();
        }
开发者ID:JoseManuelLopez,项目名称:cocos-sharp-samples,代码行数:45,代码来源:SpriteWithColor.cs

示例2: IntroLayer

 public IntroLayer(string jsonurl, CCSize size)
     : base(size)
 {
     //AnchorPoint = new CCPoint(0, 0);
     //Scene.Position = new CCPoint(-484.666f, 79.78197f);
     //Scale = 41;
 }
开发者ID:netonjm,项目名称:RubeLoader,代码行数:7,代码来源:IntroLayer.cs

示例3: GameLayer

 public GameLayer(CCSize screenSize, CCClipMode clipmode)
     : base(screenSize, clipmode)
 {
     this.screenSize = screenSize;
     Init ();
     Schedule (RunGameLogic);
 }
开发者ID:one-ideaed,项目名称:BouncingGame,代码行数:7,代码来源:GameLayer.cs

示例4: CCTextFieldTTF

 public CCTextFieldTTF(string text, string fontName, float fontSize, CCSize dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment)
     : base(text, fontName, fontSize, dimensions, new CCLabelFormat( CCLabelFormatFlags.Unknown ) { Alignment = hAlignment,
         LineAlignment = vAlignment})
 {
     EditTitle = "Input";
     EditDescription = "Please provide input";
 }
开发者ID:ToraiRei,项目名称:cozy,代码行数:7,代码来源:CCTextFieldTTF.cs

示例5: SpriteWithColor

        public SpriteWithColor(CCColor4B bgColor, CCSize textureSizeInPixels) : base ()
        {
            // 1: Create new CCRenderTexture
            CCRenderTexture rt = new CCRenderTexture(textureSizeInPixels, textureSizeInPixels);

            // 2: Call CCRenderTexture:begin
            rt.BeginWithClear(bgColor);

            // 3: Draw into the texture
            // You'll add this later
            GenerateGradient(textureSizeInPixels);


            var noise = new CCSprite("images/Noise.png");
            noise.AnchorPoint = CCPoint.AnchorLowerLeft;
            noise.Position = CCPoint.Zero;
            noise.BlendFunc = new CCBlendFunc(CCOGLES.GL_DST_COLOR, CCOGLES.GL_ZERO);
            noise.Texture.SamplerState = Microsoft.Xna.Framework.Graphics.SamplerState.LinearWrap;

            // To get the linear wrap to work correctly we have to set the TextureRectInPixels as well as ContentSize
            noise.TextureRectInPixels = new CCRect(0, 0, textureSizeInPixels.Width, textureSizeInPixels.Height);
            noise.ContentSize = noise.TextureRectInPixels.Size;
            noise.Visit();

            // 4: Call CCRenderTexture:end
            rt.End();

            this.Texture = rt.Texture;

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

示例6: ApplicationDidFinishLaunching

        public override void ApplicationDidFinishLaunching(CCApplication application, CCWindow mainWindow)
        {

            CCLog.Logger = DebugLogging;

            preferredWidth = 1024;
			preferredHeight = 768;

			application.PreferMultiSampling = true;
			application.ContentRootDirectory = "Content";

			//CCSpriteFontCache.FontScale = 0.5f;
			//CCSpriteFontCache.RegisterFont("MarkerFelt", 22);
			//CCSpriteFontCache.RegisterFont("arial", 12, 24);

			CCSize designSize = new CCSize(480, 320);

//			if (CCDrawManager.FrameSize.Height > 320)
//			{
//				//CCSize resourceSize = new CCSize(960, 640);
//				CCSize resourceSize = new CCSize(480, 320);
//				application.ContentSearchPaths.Add("hd");
//				director.ContentScaleFactor = resourceSize.Height / designSize.Height;
//			}

            CCScene.SetDefaultDesignResolution(designSize.Width, designSize.Height, CCSceneResolutionPolicy.ShowAll);

			// turn on display FPS
			mainWindow.DisplayStats = true;
            mainWindow.StatsScale = 2;

            CCScene pScene = GoblinLayer.Scene(mainWindow);

			mainWindow.RunWithScene(pScene);
		}
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:35,代码来源:AppDelegate.cs

示例7: ApplicationDidFinishLaunching

        public override bool ApplicationDidFinishLaunching()
        {
            ContentRootDirectory = "Content";

            CCSpriteFontCache.FontScale = 0.6f;
            CCSpriteFontCache.RegisterFont("MarkerFelt", 22);

            CCDirector director = CCDirector.SharedDirector;
            director.DisplayStats = true;
            director.AnimationInterval = 1.0 / 60;

            CCSize designSize = new CCSize(480, 320);

            if (CCDrawManager.FrameSize.Height > 320)
            {
                CCSize resourceSize = new CCSize(960, 640);
                ContentSearchPaths.Add("hd");
                director.ContentScaleFactor = resourceSize.Height / designSize.Height;
            }

            CCDrawManager.SetDesignResolutionSize(designSize.Width, designSize.Height, CCResolutionPolicy.ShowAll);

            CCScene scene = new CCScene();

            var label = TestClass.PCLLabel(AppDelegate.PlatformMessage());

            scene.AddChild(label);

            director.RunWithScene(scene);

            return true;
        }
开发者ID:KerwinMa,项目名称:CocosSharp,代码行数:32,代码来源:AppDelegate.cs

示例8: CCRenderTexture

        public CCRenderTexture(CCSize contentSize, CCSize textureSizeInPixels, 
            CCSurfaceFormat colorFormat=CCSurfaceFormat.Color, 
            CCDepthFormat depthFormat=CCDepthFormat.None, 
            CCRenderTargetUsage usage=CCRenderTargetUsage.DiscardContents) : this()
        {
            int textureWidth = (int)textureSizeInPixels.Width;
            int textureHeight = (int)textureSizeInPixels.Height;

            renderTarget2D = drawManager.CreateRenderTarget(
                textureWidth, textureHeight, colorFormat, depthFormat, usage);

            Texture = new CCTexture2D(renderTarget2D, colorFormat, true, false);
            Texture.IsAntialiased = false;

            Sprite = new CCSprite(Texture);
            Sprite.ContentSize = contentSize;
            Sprite.BlendFunc = CCBlendFunc.AlphaBlend;

            CCPoint center = contentSize.Center;

            renderViewMatrix = 
                Matrix.CreateLookAt(new CCPoint3(center, 300.0f).XnaVector, new CCPoint3(center, 0.0f).XnaVector, Vector3.Up);
            renderProjMatrix = 
                Matrix.CreateOrthographic(contentSize.Width, contentSize.Height, 1024f, -1024);
            renderViewport = new Viewport(0, 0, textureWidth, textureHeight);


            clearColor = CCColor4B.Transparent;
            drawManager.SetRenderTarget(Texture);
            drawManager.Clear(clearColor);
            drawManager.RestoreRenderTarget();
        }
开发者ID:KevinHeyer,项目名称:CocosSharp,代码行数:32,代码来源:CCRenderTexture.cs

示例9: OnEnter

        public override void OnEnter()
        {
            base.OnEnter(); CCSize windowSize = Layer.VisibleBoundsWorldspace.Size;

            spritePremulti.Position = new CCPoint(16, 48);
            spriteNonpremulti.Position = new CCPoint(16, 16);

            CCSize rendSize = new CCSize(32, 64);

            /* A2 & B2 setup */
            CCRenderTexture rend = new CCRenderTexture(rendSize,rendSize);

            //  It's possible to modify the RenderTexture blending function by
            //  CCBlendFunc bf = new CCBlendFunc (OGLES.GL_ONE, OGLES.GL_ONE_MINUS_SRC_ALPHA);
            //  rend.Sprite.BlendFunc = bf;

            rend.BeginWithClear(CCColor4B.Transparent);
            // A2
            spritePremulti.Visit();
            // B2
            spriteNonpremulti.Visit();
            rend.End();

            /* A1: setup */
            spritePremulti.Position = new CCPoint(windowSize.Width / 2 - 16, windowSize.Height / 2 + 16);
            /* B1: setup */
            spriteNonpremulti.Position = new CCPoint(windowSize.Width / 2 - 16, windowSize.Height / 2 - 16);

            rend.Sprite.Position = new CCPoint(windowSize.Width / 2 + 16, windowSize.Height / 2);

            AddChild(spriteNonpremulti);
            AddChild(spritePremulti);
            AddChild(rend.Sprite);
        }
开发者ID:KevinHeyer,项目名称:CocosSharp,代码行数:34,代码来源:RenderTextureIssue937.cs

示例10: Background

 public Background(CCSize size, CCColor4B color)
 {
     Color = new CCColor3B(color);
     Opacity = color.A;
     AnchorPoint = CCPoint.AnchorMiddle;
     ContentSize = size;
 }
开发者ID:KerwinMa,项目名称:CocosSharp,代码行数:7,代码来源:RotateWorldMainLayer.cs

示例11: CCNodeGrid

 public CCNodeGrid(CCSize contentSize) 
     : base(contentSize)
 {
     renderGrid = new CCCustomCommand(RenderGrid);
     renderBeginGrid = new CCCustomCommand(float.MinValue, OnGridBeginDraw);
     renderEndGrid = new CCCustomCommand(float.MaxValue, OnGridEndDraw); 
 }
开发者ID:KevinHeyer,项目名称:CocosSharp,代码行数:7,代码来源:CCNodeGrid.cs

示例12: AlignmentPanel

 public AlignmentPanel(CCSize size, CCColor4B color)
 {
     Color = new CCColor3B(color);
     Opacity = color.A;
     //AnchorPoint = CCPoint.AnchorMiddle;
     ContentSize = size;
 }
开发者ID:h7ing,项目名称:CocosSharp,代码行数:7,代码来源:LabelTTFTest.cs

示例13: CreateNativeLabel

        internal static CCTexture2D CreateNativeLabel(string text, CCSize dimensions, CCTextAlignment hAlignment,
		                                   CCVerticalTextAlignment vAlignment, string fontName,
		                                   float fontSize, CCColor4B textColor)
		{

		    if (string.IsNullOrEmpty(text))
		    {
		        return new CCTexture2D();
		    }

		    var font = CreateFont (fontName, fontSize);

            if (dimensions.Equals(CCSize.Zero))
            {
                CreateBitmap(1, 1);

                var ms = _graphics.MeasureString(text, font);
                
                dimensions.Width = ms.Width;
                dimensions.Height = ms.Height;
            }

            CreateBitmap((int)dimensions.Width, (int)dimensions.Height);

            var stringFormat = new StringFormat();

		    switch (hAlignment)
		    {
		        case CCTextAlignment.Left:
                    stringFormat.Alignment = StringAlignment.Near;
		            break;
		        case CCTextAlignment.Center:
                    stringFormat.Alignment = StringAlignment.Center;
		            break;
		        case CCTextAlignment.Right:
                    stringFormat.Alignment = StringAlignment.Far;
		            break;
		    }

		    switch (vAlignment)
		    {
		        case CCVerticalTextAlignment.Top:
        		    stringFormat.LineAlignment = StringAlignment.Near;
		            break;
		        case CCVerticalTextAlignment.Center:
        		    stringFormat.LineAlignment = StringAlignment.Center;
		            break;
		        case CCVerticalTextAlignment.Bottom:
        		    stringFormat.LineAlignment = StringAlignment.Far;
		            break;
		    }

            _graphics.DrawString(text, font, _brush, new RectangleF(0, 0, dimensions.Width, dimensions.Height), stringFormat);
            _graphics.Flush();

            var texture = new CCTexture2D(SaveToStream(), CCSurfaceFormat.Bgra4444);

			return texture;
		}
开发者ID:KerwinMa,项目名称:CocosSharp,代码行数:59,代码来源:CCLabelUtilities-Gdi.cs

示例14: updateSize

        public void updateSize(CCPoint touchLocation)
        {
            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            CCSize newSize = new CCSize(Math.Abs(touchLocation.X - s.Width / 2) * 2, Math.Abs(touchLocation.Y - s.Height / 2) * 2);
            CCLayerColor l = (CCLayerColor)GetChildByTag(kTagLayer);
            l.ContentSize = newSize;
        }
开发者ID:h7ing,项目名称:CocosSharp,代码行数:8,代码来源:LayerTest1.cs

示例15: WorldToScreen

 public static CCPoint WorldToScreen(b2Vec2 worldPos, CCPoint actualPosition, float actualScale, CCSize wSize)
 {
     worldPos *= actualScale;
     CCPoint layerOffset = actualPosition;
     CCPoint p = new CCPoint(worldPos.x + layerOffset.X, worldPos.y + layerOffset.Y);
     p.Y = wSize.Height - p.Y;
     return p;
 }
开发者ID:netonjm,项目名称:RubeLoader,代码行数:8,代码来源:RubeBasicLayer.cs


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