本文整理汇总了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();
}
示例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;
}
示例3: GameLayer
public GameLayer(CCSize screenSize, CCClipMode clipmode)
: base(screenSize, clipmode)
{
this.screenSize = screenSize;
Init ();
Schedule (RunGameLogic);
}
示例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";
}
示例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;
}
示例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);
}
示例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;
}
示例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();
}
示例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);
}
示例10: Background
public Background(CCSize size, CCColor4B color)
{
Color = new CCColor3B(color);
Opacity = color.A;
AnchorPoint = CCPoint.AnchorMiddle;
ContentSize = size;
}
示例11: CCNodeGrid
public CCNodeGrid(CCSize contentSize)
: base(contentSize)
{
renderGrid = new CCCustomCommand(RenderGrid);
renderBeginGrid = new CCCustomCommand(float.MinValue, OnGridBeginDraw);
renderEndGrid = new CCCustomCommand(float.MaxValue, OnGridEndDraw);
}
示例12: AlignmentPanel
public AlignmentPanel(CCSize size, CCColor4B color)
{
Color = new CCColor3B(color);
Opacity = color.A;
//AnchorPoint = CCPoint.AnchorMiddle;
ContentSize = size;
}
示例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;
}
示例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;
}
示例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;
}