本文整理汇总了C#中CCTexture2D类的典型用法代码示例。如果您正苦于以下问题:C# CCTexture2D类的具体用法?C# CCTexture2D怎么用?C# CCTexture2D使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CCTexture2D类属于命名空间,在下文中一共展示了CCTexture2D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CCMotionStreak
public CCMotionStreak(float fade, float minSegIn, float strokeIn, CCColor3B color, CCTexture2D texture)
{
streakRenderCommand = new CCCustomCommand(RenderMotionStreak);
AnchorPoint = CCPoint.Zero;
IgnoreAnchorPointForPosition = true;
StartingPositionInitialized = false;
FastMode = true;
Texture = texture;
Color = color;
stroke = strokeIn;
BlendFunc = CCBlendFunc.NonPremultiplied;
minSeg = (minSegIn == -1.0f) ? stroke / 5.0f : minSegIn;
minSeg *= minSeg;
fadeDelta = 1.0f / fade;
maxPoints = (int) (fade * 60.0f) + 2;
pointState = new float[maxPoints];
pointVertexes = new CCPoint[maxPoints];
vertices = new CCV3F_C4B_T2F[(maxPoints + 1) * 2];
Schedule();
}
示例2: 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();
}
示例3: 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;
}
示例4: CCGridBase
protected CCGridBase(CCGridSize gridSize, CCTexture2D texture, bool flipped=false)
{
GridSize = gridSize;
Texture = texture;
textureFlipped = flipped;
CCSize texSize = texture.ContentSizeInPixels;
Step = new CCPoint ((float)Math.Ceiling(texSize.Width / GridSize.X), (float)Math.Ceiling(texSize.Height / GridSize.Y));
}
示例5: Render
public void Render (DrawBatch drawBatch, CCTexture2D defaultTexture)
{
//device.Textures[0] = _texture ?? defaultTexture;
//device.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, _vertexBuffer, 0, _vertexBuffer.Length, _indexBuffer, 0, _indexBuffer.Length / 3);
drawBatch.RenderBatch(PrimitiveType.TriangleList,
0, _indexBuffer.Length, _indexBuffer,
0, _vertexBuffer.Length, _vertexBuffer,
_texture ?? defaultTexture);
}
示例6: CCQuadCommand
public CCQuadCommand(float globalDepth, CCAffineTransform worldTransform,
CCTexture2D texture, CCBlendFunc blendType, int quadCount,
params CCV3F_C4B_T2F_Quad[] quads)
: base(globalDepth, worldTransform)
{
Quads = quads;
QuadCount = quadCount;
Texture = texture;
BlendType = blendType;
}
示例7: 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;
}
示例8: AddSpriteSheet
public CCSpriteSheet AddSpriteSheet(string fileName, CCTexture2D texture)
{
CCSpriteSheet result;
if (!_spriteSheets.TryGetValue(fileName, out result))
{
result = new CCSpriteSheet(fileName, texture);
_spriteSheets.Add(fileName, result);
}
return result;
}
示例9: BackgroungLayer
/// <summary>
///
/// </summary>
/// <param name="bgFile"></param>
public BackgroungLayer(string bgFile, byte opacity = 255)
: base()
{
BackgroundSprite =
new CCSprite(BackgroundTexture =
new CCTexture2D(BACKGROUND_FOLDER + bgFile));
BackgroundSprite.AnchorPoint = CCPoint.AnchorLowerLeft;
BackgroundSprite.Opacity = opacity;
Opacity = opacity;
AddChild(BackgroundSprite);
}
示例10: InitializeTTFAtlas
public static void InitializeTTFAtlas(int width, int height)
{
m_nWidth = width;
m_nHeight = height;
m_nDepth = 4;
m_pTexture = new CCTexture2D();
m_pData = new int[width * height];
m_pNodes.Clear();
m_pNodes.Add(new ivec3() { x = 1, y = 1, z = m_nWidth - 2 });
}
示例11: DrawCacheUnit
public DrawCacheUnit (VertexPositionColorTexture[] vertexBuffer, int vertexOffset, int vertexCount, short[] indexBuffer, int indexOffset, int indexCount, CCTexture2D texture)
{
if (vertexCount > vertexBuffer.Length - vertexOffset)
throw new ArgumentException("vertexBuffer is too small for the given vertexOffset and vertexCount.");
if (indexCount > indexBuffer.Length - indexOffset)
throw new ArgumentException("indexBuffer is too small for the given indexOffset and indexCount.");
_texture = texture;
_vertexBuffer = new VertexPositionColorTexture[vertexCount];
_indexBuffer = new short[indexCount];
Array.Copy(vertexBuffer, vertexOffset, _vertexBuffer, 0, vertexCount);
Array.Copy(indexBuffer, indexOffset, _indexBuffer, 0, indexCount);
}
示例12: CCSpriteBatchNode
public CCSpriteBatchNode(CCTexture2D tex, int capacity=defaultSpriteBatchCapacity)
{
BlendFunc = CCBlendFunc.AlphaBlend;
if (capacity == 0)
{
capacity = defaultSpriteBatchCapacity;
}
TextureAtlas = new CCTextureAtlas(tex, capacity);
// no lazy alloc in this node
Children = new CCRawList<CCNode>(capacity);
Descendants = new CCRawList<CCSprite>(capacity);
}
示例13: CCTextureAtlas
public CCTextureAtlas(CCTexture2D texture, int capacity)
{
Texture = texture;
// Re-initialization is not allowed
Debug.Assert(Quads == null);
if (capacity < 4)
{
capacity = 4;
}
vertexBuffer = new CCQuadVertexBuffer(capacity, CCBufferUsage.WriteOnly);
Quads = vertexBuffer.Data;
Dirty = true;
}
示例14: TextureFill
public TextureFill()
{
var _xor6 = BuildXorTexture(6);
_xor6.SamplerState = SamplerState.LinearWrap;
_brush1 = new TextureBrush(_xor6);
_brush2 = new TextureBrush(_xor6)
{
Transform = Matrix.CreateTranslation(-50f / _xor6.XNATexture.Width, -175f / _xor6.XNATexture.Height, 0)
};
_brush3 = new TextureBrush(_xor6)
{
Transform = Matrix.CreateScale(.25f, .5f, 1f)
};
_brush4 = new TextureBrush(_xor6)
{
Transform = Matrix.CreateRotationZ((float)Math.PI / 4)
};
_brush5 = new TextureBrush(_xor6, .5f);
_brush6 = new TextureBrush(_xor6)
{
Color = Microsoft.Xna.Framework.Color.Purple
};
var pattern = new CCTexture2D("images/pattern1");
var state = new SamplerState();
state.AddressU = TextureAddressMode.Mirror;
state.AddressV = TextureAddressMode.Wrap;
pattern.SamplerState = state;
mirrorBrush = new TextureBrush(pattern)
{
Color = Microsoft.Xna.Framework.Color.White
};
var pattern2 = new CCTexture2D("images/pattern2");
pattern2.SamplerState = SamplerState.LinearWrap;
repeatBrush = new TextureBrush(pattern2);
}
示例15: CCRenderTexture
public CCRenderTexture(CCSize contentSize, CCSize textureSizeInPixels,
CCSurfaceFormat colorFormat=CCSurfaceFormat.Color,
CCDepthFormat depthFormat=CCDepthFormat.None,
CCRenderTargetUsage usage=CCRenderTargetUsage.DiscardContents)
{
int textureWidth = (int)textureSizeInPixels.Width;
int textureHeight = (int)textureSizeInPixels.Height;
firstUsage = true;
renderTarget2D = CCDrawManager.SharedDrawManager.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;
AddChild(Sprite);
}