예제 #1
0
        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
0
        /// <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)
        {
            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);
        }
예제 #3
0
 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;
 }
예제 #4
0
 public static CCTexture2D GetCCTexture2D(String p_FilePath)
 {
     Texture2D text2D = Media.PictureManager.GetTexture2D(p_FilePath);
     CCTexture2D cctext2D = new CCTexture2D();
     cctext2D.initWithTexture(text2D);
     return cctext2D;
 }
예제 #5
0
        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;
        }
예제 #6
0
        /// <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);
        }
예제 #7
0
        public CCTexture2D addImage(string fileimage)
        {
            CCTexture2D textured;

            lock (this.m_pDictLock)
            {
                string key = fileimage;
                if (this.m_pTextures.TryGetValue(key, out textured))
                {
                    return(textured);
                }
                Texture2D texture = CCApplication.sharedApplication().content.Load <Texture2D>(fileimage);
                textured = new CCTexture2D();
                if (textured.initWithTexture(texture))
                {
                    this.m_pTextures.Add(key, textured);
                    return(textured);
                }
                return(null);
            }
            return(textured);
        }
        /// <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;
        }
예제 #9
0
        /// <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;
        }
예제 #10
0
 public static CCTexture2D GetCCTexture2DWithFile(String p_ContentFileName)
 {
     CCTexture2D cctext2D = new CCTexture2D();
     cctext2D.initWithTexture(CCApplication.sharedApplication().content.Load<Texture2D>(p_ContentFileName));
     return cctext2D;
 }
예제 #11
0
 public static CCTexture2D GetCCTexture2D(Stream p_PicStrean, Int32 p_Width, Int32 p_Height, bool p_Zoom)
 {
     Texture2D text2D = Texture2D.FromStream(CCApplication.sharedApplication().GraphicsDevice, p_PicStrean,p_Width,p_Height,p_Zoom);
     CCTexture2D cctext2D = new CCTexture2D();
     cctext2D.initWithTexture(text2D);
     return cctext2D;
 }
예제 #12
0
 public static CCTexture2D GetCCTexture2D(Word p_Word, Int32 p_Width, Int32 p_Height, bool p_Zoom)
 {
     Texture2D text2D = GetTexture2D(p_Word,p_Width,p_Height,p_Zoom);
     CCTexture2D cctext2D = new CCTexture2D();
     cctext2D.initWithTexture(text2D);
     return cctext2D;
 }
예제 #13
0
 public static CCTexture2D GetCCTexture2D(Word p_Word)
 {
     CCTexture2D result = new CCTexture2D();
     result.initWithTexture(GetTexture2D(p_Word));
     return result;
 }