Beispiel #1
0
 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;
 }
Beispiel #2
0
        public override void Draw()
        {
            if (m_bFontDirty)
            {
                m_pConfiguration = InitializeFont(m_FontName, m_FontSize, Text);
                m_bFontDirty     = false;
            }

            if (m_bTextureDirty)
            {
                m_pTexture.InitWithRawData(m_pData, SurfaceFormat.Color, m_nWidth, m_nHeight, true);
                m_bTextureDirty = false;
            }

            base.Draw();
        }
Beispiel #3
0
        public CCTexture2D AddRawImage <T>(T[] data, int width, int height, string assetName, SurfaceFormat format,
                                           bool premultiplied, bool mipMap, CCSize contentSize) where T : struct
        {
            CCTexture2D texture;

            lock (m_pDictLock)
            {
                if (!m_pTextures.TryGetValue(assetName, out texture))
                {
                    texture = new CCTexture2D();

                    if (texture.InitWithRawData(data, format, width, height, premultiplied, mipMap, contentSize))
                    {
                        m_pTextures.Add(assetName, texture);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            return(texture);
        }