本文整理汇总了C#中Cocos2D.CCTexture2D类的典型用法代码示例。如果您正苦于以下问题:C# CCTexture2D类的具体用法?C# CCTexture2D怎么用?C# CCTexture2D使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CCTexture2D类属于Cocos2D命名空间,在下文中一共展示了CCTexture2D类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: 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();
texture.InitWithStream (SaveToStream(), Microsoft.Xna.Framework.Graphics.SurfaceFormat.Bgra4444);
return texture;
}
开发者ID:Karunp,项目名称:cocos2d-xna,代码行数:60,代码来源:CCLabelUtilities-Gdi.cs
示例2: InitWithSize
protected virtual bool InitWithSize(CCGridSize gridSize, CCTexture2D pTexture, bool bFlipped)
{
bool bRet = true;
m_bActive = false;
m_nReuseGrid = 0;
m_sGridSize = gridSize;
m_pTexture = pTexture;
m_bIsTextureFlipped = bFlipped;
CCSize texSize = m_pTexture.ContentSize;
m_obStep.X = texSize.Width / m_sGridSize.X;
m_obStep.Y = texSize.Height / m_sGridSize.Y;
m_pGrabber = new CCGrabber();
if (m_pGrabber != null)
{
m_pGrabber.Grab(m_pTexture);
}
else
{
bRet = false;
}
//m_pShaderProgram = CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionTexture);
CalculateVertexPoints();
return bRet;
}
开发者ID:CartBlanche,项目名称:cocos2d-xna,代码行数:31,代码来源:CCGridBase.cs
示例3: CreateAtlasFromTexture2D
public static CCTextureAtlas CreateAtlasFromTexture2D(Microsoft.Xna.Framework.Graphics.Texture2D texture2d)
{
CCTexture2D texture = new CCTexture2D();
texture.InitWithTexture(texture2d);
CCTextureAtlas textureAtlas = CCTextureAtlas.Create(texture, 128);
return textureAtlas;
}
开发者ID:netonjm,项目名称:spine-runtimes,代码行数:8,代码来源:spine-cocos2dx.cs
示例4: CreateTexture
public static Cocos2D.CCTexture2D CreateTexture(Stream stream)
{
PngDecoder png = new PngDecoder();
byte[] colors = png.Decode(stream);
CCTexture2D cctexture = new CCTexture2D();
cctexture.InitWithRawData<byte>(colors, Microsoft.Xna.Framework.Graphics.SurfaceFormat.Color, png.Width, png.Height, false);
return cctexture;
}
开发者ID:liwq-net,项目名称:UIFactory,代码行数:8,代码来源:Factory.cs
示例5: initWithTexture
public bool initWithTexture(CCTexture2D aTexture)
{
if (base.InitWithTexture(aTexture))
{
m_state = PaddleState.kPaddleStateUngrabbed;
}
return true;
}
开发者ID:pekayatt,项目名称:cocos2d-xna,代码行数:8,代码来源:Paddle.cs
示例6: InitWithTexture
/*
* init with CCTexture2D
*/
public bool InitWithTexture(CCTexture2D tex, int capacity)
{
TextureAtlas.InitWithTexture(tex, capacity);
// no lazy alloc in this node
m_pChildren = new CCRawList<CCNode>(capacity);
m_tBlendFunc = CCBlendFunc.AlphaBlend;
return true;
}
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:15,代码来源:CCParticleBatchNode.cs
示例7: 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 });
}
开发者ID:huaqiangs,项目名称:cocos2d-xna,代码行数:12,代码来源:CCLabel.cs
示例8: InitWithTexture
/*
* init with CCTexture2D
*/
public bool InitWithTexture(CCTexture2D tex, int capacity)
{
TextureAtlas.InitWithTexture(tex, capacity);
// no lazy alloc in this node
m_pChildren = new CCRawList<CCNode>(capacity);
m_tBlendFunc.Source = CCMacros.CCDefaultSourceBlending;
m_tBlendFunc.Destination = CCMacros.CCDefaultDestinationBlending;
//setShaderProgram(CCShaderCache::sharedShaderCache().programForKey(kCCShader_PositionTextureColor));
return true;
}
开发者ID:CartBlanche,项目名称:cocos2d-xna,代码行数:18,代码来源:CCParticleBatchNode.cs
示例9: MakeTexture
private void MakeTexture()
{
m_pTexture = new CCTexture2D();
m_pTexture.OnReInit = TextureReInit;
m_pTexture.IsAntialiased = false;
m_pRenderTarget2D = CCDrawManager.CreateRenderTarget(m_Width, m_Height, m_ColorFormat, m_DepthFormat, m_Usage);
m_pTexture.InitWithTexture(m_pRenderTarget2D, m_ColorFormat, true, false);
m_bFirstUsage = true;
m_pSprite = new CCSprite(m_pTexture);
//m_pSprite.scaleY = -1;
m_pSprite.BlendFunc = CCBlendFunc.AlphaBlend;
AddChild(m_pSprite);
}
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:17,代码来源:CCRenderTexture.cs
示例10: InitWithWidthAndHeight
protected virtual bool InitWithWidthAndHeight(int w, int h, SurfaceFormat colorFormat, DepthFormat depthFormat, RenderTargetUsage usage)
{
w = (int)Math.Ceiling(w * CCMacros.CCContentScaleFactor());
h = (int)Math.Ceiling(h * CCMacros.CCContentScaleFactor());
m_pTexture = new CCTexture2D();
m_pTexture.IsAntialiased = false;
m_pRenderTarget2D = CCDrawManager.CreateRenderTarget(w, h, colorFormat, depthFormat, usage);
m_pTexture.InitWithTexture(m_pRenderTarget2D, colorFormat, true, false);
m_bFirstUsage = true;
m_pSprite = new CCSprite(m_pTexture);
//m_pSprite.scaleY = -1;
m_pSprite.BlendFunc = CCBlendFunc.AlphaBlend;
AddChild(m_pSprite);
return true;
}
开发者ID:womandroid,项目名称:cocos2d-xna,代码行数:21,代码来源:CCRenderTexture.cs
示例11: InitWithWidthAndHeight
protected virtual bool InitWithWidthAndHeight(int w, int h, SurfaceFormat colorFormat, DepthFormat depthFormat, RenderTargetUsage usage)
{
w = (w * CCMacros.CCContentScaleFactor());
h = (h * CCMacros.CCContentScaleFactor());
m_pTexture = new CCTexture2D();
m_pTexture.SetAliasTexParameters();
m_pRenderTarget2D = CCDrawManager.CreateRenderTarget(w, h, colorFormat, depthFormat, usage);
m_pTexture.InitWithTexture(m_pRenderTarget2D);
m_bFirstUsage = true;
m_pSprite = new CCSprite(m_pTexture);
//m_pSprite.scaleY = -1;
m_pSprite.BlendFunc = new CCBlendFunc(CCMacros.CCDefaultSourceBlending, CCMacros.CCDefaultDestinationBlending); // OGLES.GL_ONE, OGLES.GL_ONE_MINUS_SRC_ALPHA);
AddChild(m_pSprite);
return true;
}
开发者ID:CartBlanche,项目名称:cocos2d-xna,代码行数:21,代码来源:CCRenderTexture.cs
示例12: InitWithTexture
protected virtual bool InitWithTexture(CCTexture2D tex, int capacity)
{
m_blendFunc = CCBlendFunc.AlphaBlend;
m_pobTextureAtlas = new CCTextureAtlas();
if (capacity == 0)
{
capacity = kDefaultSpriteBatchCapacity;
}
ContentSize= tex.ContentSize; // @@ TotallyEvil - contentSize should return the size of the sprite sheet
m_pobTextureAtlas.InitWithTexture(tex, capacity);
UpdateBlendFunc();
// no lazy alloc in this node
m_pChildren = new CCRawList<CCNode>(capacity);
m_pobDescendants = new CCRawList<CCSprite>(capacity);
return true;
}
开发者ID:Karunp,项目名称:cocos2d-xna,代码行数:22,代码来源:CCSpriteBatchNode.cs
示例13: AddSpriteFramesWithDictionary
public void AddSpriteFramesWithDictionary(PlistDictionary pobDictionary, CCTexture2D pobTexture)
{
AddSpriteFramesWithDictionary(pobDictionary, pobTexture, string.Empty);
}
开发者ID:nilcrabaniel,项目名称:cocos2d-xna,代码行数:4,代码来源:CCSpriteFrameCache.cs
示例14: AddSpriteFramesWithFile
/// <summary>
///
/// </summary>
/// <param name="pszPlist"></param>
/// <param name="pobTexture"></param>
/// <param name="framePrefix"></param>
/// <returns>The framePrefix parameter</returns>
public string AddSpriteFramesWithFile(string pszPlist, CCTexture2D pobTexture, string framePrefix)
{
PlistDocument document = CCContentManager.SharedContentManager.Load<PlistDocument>(pszPlist);
PlistDictionary dict = document.Root.AsDictionary;
AddSpriteFramesWithDictionary(dict, pobTexture, framePrefix);
return (framePrefix);
}
开发者ID:nilcrabaniel,项目名称:cocos2d-xna,代码行数:16,代码来源:CCSpriteFrameCache.cs
示例15: updateTexture
private void updateTexture()
{
CCTexture2D tex;
// Dump the old one
if (Texture != null)
{
Texture.Dispose();
}
// let system compute label's width or height when its value is 0
// refer to cocos2d-x issue #1430
tex = new CCTexture2D();
tex.InitWithString(m_pString,
CCMacros.CCSizePointsToPixels(m_tDimensions),
m_hAlignment,
m_vAlignment,
m_pFontName,
m_fFontSize * CCMacros.CCContentScaleFactor());
Texture = tex;
CCRect rect = CCRect.Zero;
rect.Size = m_pobTexture.ContentSize;
SetTextureRect(rect);
}
开发者ID:pekayatt,项目名称:cocos2d-xna,代码行数:27,代码来源:CCLabelTTF.cs
示例16: InitWithString
protected virtual bool InitWithString(string theString, string fntFile, CCSize dimentions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment,
CCPoint imageOffset, CCTexture2D texture)
{
Debug.Assert(m_pConfiguration == null, "re-init is no longer supported");
Debug.Assert((theString == null && fntFile == null) || (theString != null && fntFile != null),
"Invalid params for CCLabelBMFont");
if (!String.IsNullOrEmpty(fntFile))
{
CCBMFontConfiguration newConf = FNTConfigLoadFile(fntFile);
if (newConf == null)
{
CCLog.Log("CCLabelBMFont: Impossible to create font. Please check file: '{0}'", fntFile);
return false;
}
m_pConfiguration = newConf;
m_sFntFile = fntFile;
if (texture == null)
{
try
{
texture = CCTextureCache.SharedTextureCache.AddImage(m_pConfiguration.AtlasName);
}
catch (Exception)
{
// Try the 'images' ref location just in case.
try
{
texture =
CCTextureCache.SharedTextureCache.AddImage(System.IO.Path.Combine("images",
m_pConfiguration
.AtlasName));
}
catch (Exception)
{
// Lastly, try <font_path>/images/<font_name>
string dir = System.IO.Path.GetDirectoryName(m_pConfiguration.AtlasName);
string fname = System.IO.Path.GetFileName(m_pConfiguration.AtlasName);
string newName = System.IO.Path.Combine(System.IO.Path.Combine(dir, "images"), fname);
texture = CCTextureCache.SharedTextureCache.AddImage(newName);
}
}
}
}
else
{
texture = new CCTexture2D();
}
if (String.IsNullOrEmpty(theString))
{
theString = String.Empty;
}
if (base.InitWithTexture(texture, theString.Length))
{
m_tDimensions = dimentions;
m_pHAlignment = hAlignment;
m_pVAlignment = vAlignment;
m_cDisplayedOpacity = m_cRealOpacity = 255;
m_tDisplayedColor = m_tRealColor = CCTypes.CCWhite;
m_bCascadeOpacityEnabled = true;
m_bCascadeColorEnabled = true;
m_obContentSize = CCSize.Zero;
m_bIsOpacityModifyRGB = m_pobTextureAtlas.Texture.HasPremultipliedAlpha;
AnchorPoint = new CCPoint(0.5f, 0.5f);
m_tImageOffset = imageOffset;
m_pReusedChar = new CCSprite();
m_pReusedChar.InitWithTexture(m_pobTextureAtlas.Texture, CCRect.Zero, false);
m_pReusedChar.BatchNode = this;
SetString(theString, true);
return true;
}
return false;
}
开发者ID:huaqiangs,项目名称:cocos2d-xna,代码行数:86,代码来源:CCLabelBMFont.cs
示例17: AddSpriteFramesWithFile
public void AddSpriteFramesWithFile(string pszPlist, CCTexture2D pobTexture)
{
PlistDocument document = CCContentManager.SharedContentManager.Load<PlistDocument>(pszPlist);
PlistDictionary dict = document.Root.AsDictionary;
AddSpriteFramesWithDictionary(dict, pobTexture);
}
开发者ID:womandroid,项目名称:cocos2d-xna,代码行数:8,代码来源:CCSpriteFrameCache.cs
示例18: CCParticleBatchNode
public CCParticleBatchNode (CCTexture2D tex, int capacity /* = kCCParticleDefaultCapacity*/)
{
InitWithTexture(tex, capacity);
}
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:4,代码来源:CCParticleBatchNode.cs
示例19: InitWithFade
public bool InitWithFade(float fade, float minSeg, float stroke, CCColor3B color, CCTexture2D texture)
{
Position = CCPoint.Zero;
AnchorPoint = CCPoint.Zero;
IgnoreAnchorPointForPosition = true;
m_bStartingPositionInitialized = false;
m_tPositionR = CCPoint.Zero;
m_bFastMode = true;
m_fMinSeg = (minSeg == -1.0f) ? stroke / 5.0f : minSeg;
m_fMinSeg *= m_fMinSeg;
m_fStroke = stroke;
m_fFadeDelta = 1.0f / fade;
m_uMaxPoints = (int) (fade * 60.0f) + 2;
m_uNuPoints = 0;
m_pPointState = new float[m_uMaxPoints];
m_pPointVertexes = new CCPoint[m_uMaxPoints];
m_pVertices = new CCV3F_C4B_T2F[(m_uMaxPoints + 1) * 2];
// Set blend mode
m_tBlendFunc.Source = CCOGLES.GL_SRC_ALPHA;
m_tBlendFunc.Destination = CCOGLES.GL_ONE_MINUS_SRC_ALPHA;
// shader program
// setShaderProgram(CCShaderCache.sharedShaderCache().programForKey(kCCShader_PositionTextureColor));
Texture = texture;
Color = color;
ScheduleUpdate();
return true;
}
开发者ID:CartBlanche,项目名称:cocos2d-xna,代码行数:35,代码来源:CCMotionStreak.cs
示例20: AddSpriteFrameWithTexture
public void AddSpriteFrameWithTexture(CCTexture2D pobTexture, CCRect rect)
{
CCSpriteFrame pFrame = new CCSpriteFrame(pobTexture, rect);
AddSpriteFrame(pFrame);
}
开发者ID:Ratel13,项目名称:cocos2d-xna,代码行数:5,代码来源:CCAnimation.cs
注:本文中的Cocos2D.CCTexture2D类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论