本文整理汇总了C#中cocos2d.CCTexture2D.initWithTexture方法的典型用法代码示例。如果您正苦于以下问题:C# CCTexture2D.initWithTexture方法的具体用法?C# CCTexture2D.initWithTexture怎么用?C# CCTexture2D.initWithTexture使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cocos2d.CCTexture2D
的用法示例。
在下文中一共展示了CCTexture2D.initWithTexture方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Selection
public Selection(Word p_StudyInfo, bool p_IsAnswer,Int32 p_Width,Int32 p_Height)
{
base.init();
this.StudyInfo = p_StudyInfo;
CCTexture2D texture = new CCTexture2D();
texture.initWithTexture(PictureManager.GetTexture2D(p_StudyInfo));
if (p_Width < texture.ContentSizeInPixels.width)
{
this.scaleX = p_Width / texture.ContentSizeInPixels.width;
}
if (p_Height < texture.ContentSizeInPixels.height)
{
this.scaleY = p_Height / texture.ContentSizeInPixels.height;
}
this.contentSize.width = p_Width;
this.contentSize.height = p_Height;
CCRect rect = new CCRect();
rect.size = new CCSize(texture.ContentSizeInPixels.width, texture.ContentSizeInPixels.height);
this.initWithTexture(texture, rect);
this.IsAnswer = p_IsAnswer;
LoadResultPeople();
}
示例2: GetCCTexture2D
public static CCTexture2D GetCCTexture2D(Stream p_PicStrean)
{
Texture2D text2D = Texture2D.FromStream(CCApplication.sharedApplication().GraphicsDevice, p_PicStrean);
CCTexture2D cctext2D = new CCTexture2D();
cctext2D.initWithTexture(text2D);
return cctext2D;
}
示例3: GetCCTexture2D
public static CCTexture2D GetCCTexture2D(Word p_Word,Int32 p_Width,Int32 p_Height,bool p_Zoom)
{
CCTexture2D result = new CCTexture2D();
result.initWithTexture(GetTexture2D(p_Word),new CCSize(p_Width,p_Height));
return result;
}
示例4: initWithWidthAndHeight
/// <summary>
/// initializes a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid
/// </summary>
public bool initWithWidthAndHeight(int w, int h, CCTexture2DPixelFormat eFormat)
{
// If the gles version is lower than GLES_VER_1_0,
// some extended gles functions can't be implemented, so return false directly.
if (CCConfiguration.sharedConfiguration().getGlesVersion() <= CCGlesVersion.GLES_VER_1_0)
{
return false;
}
bool bRet = false;
do
{
w *= (int)CCDirector.sharedDirector().ContentScaleFactor;
h *= (int)CCDirector.sharedDirector().ContentScaleFactor;
//glGetIntegerv(0x8CA6, m_nOldFBO);
// textures must be power of two squared
uint powW = (uint)ccUtils.ccNextPOT(w);
uint powH = (uint)ccUtils.ccNextPOT(h);
m_pTexture = new CCTexture2D();
CCApplication app = CCApplication.sharedApplication();
m_RenderTarget2D = new RenderTarget2D(app.GraphicsDevice, (int)w, (int)h);
app.GraphicsDevice.SetRenderTarget(m_RenderTarget2D);
app.GraphicsDevice.Clear(new Microsoft.Xna.Framework.Color(0, 0, 0, 0));
m_pTexture.initWithTexture(m_RenderTarget2D);
// generate FBO
//ccglGenFramebuffers(1, &m_uFBO);
//ccglBindFramebuffer(CC_GL_FRAMEBUFFER, m_uFBO);
// associate texture with FBO
//ccglFramebufferTexture2D(CC_GL_FRAMEBUFFER, CC_GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_pTexture->getName(), 0);
// check if it worked (probably worth doing :) )
//GLuint status = ccglCheckFramebufferStatus(CC_GL_FRAMEBUFFER);
//if (status != CC_GL_FRAMEBUFFER_COMPLETE)
//{
// CCAssert(0, "Render Texture : Could not attach texture to framebuffer");
// CC_SAFE_DELETE(m_pTexture);
// break;
//}
//m_pTexture.setAliasTexParameters();
m_pSprite = CCSprite.spriteWithTexture(m_pTexture);
//m_pTexture->release();
//m_pSprite.scaleY = -1;
this.addChild(m_pSprite);
ccBlendFunc tBlendFunc = new ccBlendFunc { src = 1, dst = 0x0303 };
m_pSprite.BlendFunc = tBlendFunc;
//ccglBindFramebuffer(CC_GL_FRAMEBUFFER, m_nOldFBO);
bRet = true;
} while (false);
return bRet;
}
示例5: addImage
/// <summary>
/// Returns a Texture2D object given an file image
/// If the file image was not previously loaded, it will create a new CCTexture2D
/// object and it will return it. It will use the filename as a key.
/// Otherwise it will return a reference of a previosly loaded image.
/// Supported image extensions: .png, .bmp, .tiff, .jpeg, .pvr, .gif
/// </summary>
public CCTexture2D addImage(string fileimage)
{
Debug.Assert(fileimage != null, "TextureCache: fileimage MUST not be NULL");
CCTexture2D texture;
lock (m_pDictLock)
{
//remove possible -HD suffix to prevent caching the same image twice (issue #1040)
string pathKey = fileimage;
//CCFileUtils.ccRemoveHDSuffixFromFile(pathKey);
bool isTextureExist = m_pTextures.TryGetValue(pathKey, out texture);
if (!isTextureExist)
{
//int lastPos = fileimage.LastIndexOf("1");
//if (lastPos>0)
//{
// fileimage = fileimage.Substring(0, lastPos);
//}
//if (fileimage=="Images/b")
//{
// fileimage = fileimage + "1";
//}
//if (fileimage=="Images/r")
//{
// fileimage = fileimage + "1";
//}
//if (fileimage=="Images/f")
//{
// fileimage = fileimage + "1";
//}
Texture2D textureXna = CCApplication.sharedApplication().content.Load<Texture2D>(fileimage);
texture = new CCTexture2D();
bool isInited = texture.initWithTexture(textureXna);
if (isInited)
{
m_pTextures.Add(pathKey, texture);
}
else
{
Debug.Assert(false, "cocos2d: Couldn't add image:" + fileimage + " in CCTextureCache");
return null;
}
}
}
return texture;
}
示例6: GetCCTexture2DWithFile
public static CCTexture2D GetCCTexture2DWithFile(String p_ContentFileName)
{
CCTexture2D cctext2D = new CCTexture2D();
cctext2D.initWithTexture(CCApplication.sharedApplication().content.Load<Texture2D>(p_ContentFileName));
return cctext2D;
}