Beispiel #1
0
        public void grab(ref CCTexture2D pTexture)
        {
            // If the gles version is lower than GLES_VER_1_0, 
            // all the functions in CCGrabber return directly.
            if (m_eGlesVersion <= CCGlesVersion.GLES_VER_1_0)
            {
                return;
            }

            //glGetIntegerv(CC_GL_FRAMEBUFFER_BINDING, &m_oldFBO);

            // bind
            //ccglBindFramebuffer(CC_GL_FRAMEBUFFER, m_fbo);

            m_RenderTarget2D = new RenderTarget2D(CCApplication.sharedApplication().GraphicsDevice,
                (int)pTexture.ContentSizeInPixels.width,
                (int)pTexture.ContentSizeInPixels.height);

            pTexture.Texture = m_RenderTarget2D;

            // associate texture with FBO
            //ccglFramebufferTexture2D(CC_GL_FRAMEBUFFER, CC_GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
            //pTexture->getName(), 0);

            // check if it worked (probably worth doing :) )
            //GLuint status = ccglCheckFramebufferStatus(CC_GL_FRAMEBUFFER);
            //if (status != CC_GL_FRAMEBUFFER_COMPLETE)
            //{
            //    CCLOG("Frame Grabber: could not attach texture to frmaebuffer");
            //}

            //ccglBindFramebuffer(CC_GL_FRAMEBUFFER, m_oldFBO);
        }
Beispiel #2
0
        public Box2DTestLayer()
        {
            TouchEnabled = true;
            AccelerometerEnabled = true;
            CCSize s = CCDirector.SharedDirector.WinSize;
            // init physics
            initPhysics();
            // create reset button
            createResetButton();

            //Set up sprite
            // Use batch node. Faster
            _batch = CCSpriteBatchNode.Create("Images/blocks", 100);
            m_pSpriteTexture = _batch.Texture;
            AddChild(_batch, 0, kTagParentNode);

            addNewSpriteAtPosition(new CCPoint(s.Width / 2, s.Height / 2));

            CCLabelTTF label = new CCLabelTTF("Tap screen", "Marker Felt", 32);
            AddChild(label, 0);
            label.Color = new CCColor3B(0, 0, 255);
            label.Position = new CCPoint(s.Width / 2, s.Height - 50);

            ScheduleUpdate();
        }
Beispiel #3
0
 public CCSprite(CCTexture2D texture)
 {
     if (!InitWithTexture(texture))
     {
         CCLog.Log("CCSprite (CCTexture2D texture): Problems initializing class");
     }
 }
Beispiel #4
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();
        }
 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;
 }
 public static CCTexture2D GetCCTexture2D(String p_FilePath)
 {
     Texture2D text2D = Media.PictureManager.GetTexture2D(p_FilePath);
     CCTexture2D cctext2D = new CCTexture2D();
     cctext2D.initWithTexture(text2D);
     return cctext2D;
 }
        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;
        }
Beispiel #8
0
        public static Ball ballWithTexture(CCTexture2D aTexture)
        {
            Ball pBall = new Ball();
            pBall.InitWithTexture(aTexture);
            //pBall->autorelease();

            return pBall;
        }
Beispiel #9
0
        public static Paddle paddleWithTexture(CCTexture2D aTexture)
        {
            Paddle pPaddle = new Paddle();
            pPaddle.initWithTexture(aTexture);
            //pPaddle->autorelease();

            return pPaddle;
        }
Beispiel #10
0
 public new bool initWithTexture(CCTexture2D aTexture)
 {
     if (base.initWithTexture(aTexture))
     {
         m_state = PaddleState.kPaddleStateUngrabbed;
     }
     return true;
 }
 public static CCMotionStreak create(float fade, float minSeg, float stroke, ccColor3B color, CCTexture2D texture)
 {
     CCMotionStreak pRet = new CCMotionStreak();
     if (pRet.initWithFade(fade, minSeg, stroke, color, texture))
     {
         return pRet;
     }
     return null;
 }
Beispiel #12
0
 public static CCTiledGrid3D Create(CCGridSize gridSize, CCTexture2D pTexture, bool bFlipped)
 {
     var pRet = new CCTiledGrid3D();
     if (pRet.InitWithSize(gridSize, pTexture, bFlipped))
     {
         return pRet;
     }
     return null;
 }
        public static new CCTiledGrid3D gridWithSize(ccGridSize gridSize, CCTexture2D pTexture, bool bFlipped)
        {
            CCTiledGrid3D pRet = new CCTiledGrid3D();

            if (pRet.initWithSize(gridSize, pTexture, bFlipped))
            {
                return pRet;
            }

            return null;
        }
        public void afterRender(CCTexture2D pTexture)
        {
            // If the gles version is lower than GLES_VER_1_0,
            // all the functions in CCGrabber return directly.
            if (m_eGlesVersion <= CCGlesVersion.GLES_VER_1_0)
            {
                return;
            }

            //ccglBindFramebuffer(CC_GL_FRAMEBUFFER, m_oldFBO);
            //glColorMask(true, true, true, true);	// #631
        }
        public SpriteBatchNodeNewTexture()
        {
            TouchEnabled = true;

            CCSpriteBatchNode batch = CCSpriteBatchNode.Create("Images/grossini_dance_atlas", 50);
            AddChild(batch, 0, (int)kTags.kTagSpriteBatchNode);

            m_texture1 = batch.Texture;
            m_texture2 = CCTextureCache.SharedTextureCache.AddImage("Images/grossini_dance_atlas-mono");

            for (int i = 0; i < 30; i++)
                addNewSprite();
        }
Beispiel #16
0
        public void afterRender(ref CCTexture2D pTexture)
        {
            // If the gles version is lower than GLES_VER_1_0,
            // all the functions in CCGrabber return directly.
            if (m_eGlesVersion <= CCGlesVersion.GLES_VER_1_0)
            {
                return;
            }

            CCApplication.sharedApplication().GraphicsDevice.SetRenderTarget(null);
            pTexture.texture2D = m_RenderTarget2D;

            //ccglBindFramebuffer(CC_GL_FRAMEBUFFER, m_oldFBO);
            //glColorMask(true, true, true, true);	// #631
        }
        public SpriteNewTexture()
        {
            base.TouchEnabled = true;

            CCNode node = new CCNode ();
            AddChild(node, 0, (int)kTags.kTagSpriteBatchNode);

            m_texture1 = CCTextureCache.SharedTextureCache.AddImage("Images/grossini_dance_atlas");
            m_texture2 = CCTextureCache.SharedTextureCache.AddImage("Images/grossini_dance_atlas-mono");

            m_usingTexture1 = true;

            for (int i = 0; i < 30; i++)
                addNewSprite();
        }
        public static CCGridBase gridWithSize(ccGridSize gridSize, CCTexture2D texture, bool flipped)
        {
            CCGridBase pGridBase = new CCGridBase();

            if (pGridBase != null)
            {
                if (pGridBase.initWithSize(gridSize, texture, flipped))
                {
                    //pGridBase->autorelease();
                }
                else
                {
                    //CC_SAFE_RELEASE_NULL(pGridBase);
                }
            }

            return pGridBase;
        }
        public static CCTiledGrid3D gridWithSize(ccGridSize gridSize, CCTexture2D pTexture, bool bFlipped)
        {
            CCTiledGrid3D pRet = new CCTiledGrid3D();

            if (pRet != null)
            {
                if (pRet.initWithSize(gridSize, pTexture, bFlipped))
                {
                    //pRet->autorelease();
                }
                else
                {
                    //delete pRet;
                    pRet = null;
                }
            }

            return pRet;
        }
Beispiel #20
0
        private void LoadWordText()
        {
            CCSprite sprite = new CCSprite();
            CCTexture2D texture = new CCTexture2D();

            switch (Platform.QuestionLanguage)
            {
                case Lib.Core.Language.Chinese:
                    texture.initWithString(m_Word.ChineseName, "ChineseContent", 20,Color.White,Color.Transparent);
                    break;
                case Lib.Core.Language.Enlish:
                default:
                    texture.initWithString(m_Word.EnglishName, "EnglishContent", 20, Color.White, Color.Transparent);
                    break;
            }
            sprite.initWithTexture(texture);
            sprite.Color = new ccColor3B(Color.White);
            sprite.position = new CCPoint((m_Size.width / 2) - (sprite.contentSize.width / 2) - m_StillWhile, (sprite.contentSize.height / 2));
            addChild(sprite);
        }
        public void saveImage(object pSender)
        {
            using (var stream = new MemoryStream())
            {

                m_pTarget.SaveToStream(stream, ImageFormat.PNG);
                //m_pTarget.saveToFile(jpg, ImageFormat.JPG);

                stream.Position = 0;

                Texture2D xnatex = Texture2D.FromStream(DrawManager.graphicsDevice, stream);
                var tex = new CCTexture2D();
                tex.InitWithTexture(xnatex);
                CCSprite sprite = new CCSprite(tex);

                sprite.Scale = 0.3f;
                AddChild(sprite);
                sprite.Position = new CCPoint(40, 40);
                sprite.Rotation = counter * 3;
            }
            counter++;
        }
        public void beforeRender(CCTexture2D pTexture)
        {
            // If the gles version is lower than GLES_VER_1_0,
            // all the functions in CCGrabber return directly.
            if (m_eGlesVersion <= CCGlesVersion.GLES_VER_1_0)
            {
                return;
            }

            //glGetIntegerv(CC_GL_FRAMEBUFFER_BINDING, &m_oldFBO);
            //ccglBindFramebuffer(CC_GL_FRAMEBUFFER, m_fbo);

            // BUG XXX: doesn't work with RGB565.

            /*glClearColor(0, 0, 0, 0);*/

            // BUG #631: To fix #631, uncomment the lines with #631
            // Warning: But it CCGrabber won't work with 2 effects at the same time
            //glClearColor(0.0f, 0.0f, 0.0f, 1.0f);	// #631

            //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

            //glColorMask(true, true, true, false);	// #631
        }
Beispiel #23
0
        public void beforeRender(ref CCTexture2D pTexture)
        {
            // If the gles version is lower than GLES_VER_1_0,
            // all the functions in CCGrabber return directly.
            if (m_eGlesVersion <= CCGlesVersion.GLES_VER_1_0)
            {
                return;
            }

            CCApplication.sharedApplication().GraphicsDevice.SetRenderTarget(m_RenderTarget2D);
            //CCApplication.sharedApplication().GraphicsDevice.Clear(new Color(0, 0, 0, 0));

            //CCApplication app = CCApplication.sharedApplication();
            //Texture2D td = app.content.Load<Texture2D>("Images/blocks");
            //app.spriteBatch.Begin();
            //app.spriteBatch.Draw(td, new Rectangle(100, 100, 200, 200), Color.White);
            //app.spriteBatch.End();

            //glGetIntegerv(CC_GL_FRAMEBUFFER_BINDING, &m_oldFBO);
            //ccglBindFramebuffer(CC_GL_FRAMEBUFFER, m_fbo);

            // BUG XXX: doesn't work with RGB565.

            /*glClearColor(0, 0, 0, 0);*/

            // BUG #631: To fix #631, uncomment the lines with #631
            // Warning: But it CCGrabber won't work with 2 effects at the same time
            //glClearColor(0.0f, 0.0f, 0.0f, 1.0f);	// #631

            //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

            //glColorMask(true, true, true, false);	// #631
        }
Beispiel #24
0
        public CCTexture2D AddImage(string fileimage)
        {
            Debug.Assert(!String.IsNullOrEmpty(fileimage), "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 bHasTexture = m_pTextures.TryGetValue(pathKey, out texture);
                if(!bHasTexture || texture == null)
                {
                    // Create a new one only if the current one does not exist
                    texture = new CCTexture2D();
                }
                if(!texture.IsTextureDefined)
                {
                    // Either we are creating a new one or else we need to refresh the current one.
                    // CCLog.Log("Loading texture {0}", fileimage);
                    Texture2D textureXna = null;
                    try
                    {
                        textureXna = CCApplication.SharedApplication.Content.Load<Texture2D>(fileimage);
                    }
                    catch (Exception)
                    {
                        string srcfile = fileimage;
                        if (srcfile.IndexOf('.') > -1)
                        {
                            // Remove the extension
                            srcfile = srcfile.Substring(0, srcfile.LastIndexOf('.'));
                        }
                        textureXna = CCApplication.SharedApplication.Content.Load<Texture2D>(srcfile);
                    }
                    bool isInited = texture.InitWithTexture(textureXna);

                    if (isInited)
                    {
                        texture.IsManaged = true;
                        texture.ContentFile = fileimage;
                        m_pTextures[pathKey] = texture;
                        m_pTextureRefNames[texture] = fileimage;
                    }
                    else
                    {
                        Debug.Assert(false, "cocos2d: Couldn't add image:" + fileimage + " in CCTextureCache");
                        return null;
                    }
                }
            }
            return texture;
        }
 public CCParticleSystem()
 {
     m_sPlistFile = "";
     m_fElapsed = 0;
     m_pParticles = null;
     m_fEmitCounter = 0;
     m_uParticleIdx = 0;
     #if CC_ENABLE_PROFILERS
     m_pProfilingTimer = NULL;
     #endif
     m_bIsActive = true;
     m_uParticleCount = 0;
     m_fDuration = 0;
     m_tSourcePosition = new CCPoint(0,0);
     m_tPosVar = new CCPoint(0,0);
     m_fLife = 0;
     m_fLifeVar = 0;
     m_fAngle = 0;
     m_fAngleVar = 0;
     m_fStartSize = 0;
     m_fStartSizeVar = 0;
     m_fEndSize = 0;
     m_fEndSizeVar = 0;
     m_fStartSpin = 0;
     m_fStartSpinVar = 0;
     m_fEndSpin = 0;
     m_fEndSpinVar = 0;
     m_fEmissionRate = 0;
     m_uTotalParticles = 0;
     m_pTexture = null;
     m_bIsBlendAdditive = false;
     m_ePositionType = eParticlePositionType.kCCPositionTypeFree;
     m_bIsAutoRemoveOnFinish = false;
     m_nEmitterMode = (int)eParticleMode.kCCParticleModeGravity;
     modeA = new sModeA();
     modeA.gravity = new CCPoint(0,0);
     modeA.speed = 0;
     modeA.speedVar = 0;
     modeA.tangentialAccel = 0;
     modeA.tangentialAccelVar = 0;
     modeA.radialAccel = 0;
     modeA.radialAccelVar = 0;
     modeB = new sModeB();
     modeB.startRadius = 0;
     modeB.startRadiusVar = 0;
     modeB.endRadius = 0;
     modeB.endRadiusVar = 0;
     modeB.rotatePerSecond = 0;
     modeB.rotatePerSecondVar = 0;
     m_tBlendFunc = new ccBlendFunc();
     m_tBlendFunc.src = 0;// CC_BLEND_SRC;
     m_tBlendFunc.dst = 0x0303;// CC_BLEND_DST;
 }
        /** Sets a new CCSpriteFrame as particle.
        WARNING: this method is experimental. Use setTexture:withRect instead.
        @since v0.99.4
        */
        public void setDisplayFrame(CCSpriteFrame spriteFrame)
        {
            Debug.Assert( CCPoint.CCPointEqualToPoint( spriteFrame.OffsetInPixels , new CCPoint(0,0) ), "QuadParticle only supports SpriteFrames with no offsets");

            // update texture before updating texture rect
            if ( null == this.Texture || spriteFrame.Texture.Name != this.Texture.Name)
            {
                this.Texture = spriteFrame.Texture;
            }
        }
        /** initializes a CCQuadParticleSystem from a CCDictionary.
        @since v0.99.3
        */
        bool initWithDictionary(Dictionary<string, object> dictionary)
        {
            bool bRet = false;
            string buffer;
            string deflated;
            CCTexture2D image;
            do
            {
                int maxParticles = int.Parse(ChangeToZeroIfNull(valueForKey("maxParticles", dictionary)));
                // self, not super
                if(initWithTotalParticles((uint)maxParticles))
                {
                    // angle
                    m_fAngle = float.Parse(ChangeToZeroIfNull(valueForKey("angle", dictionary)));
                    m_fAngleVar = float.Parse(ChangeToZeroIfNull(valueForKey("angleVariance", dictionary)));

                    // duration
                    m_fDuration = float.Parse(ChangeToZeroIfNull(valueForKey("duration", dictionary)));

                    // blend function
                    m_tBlendFunc.src = int.Parse(ChangeToZeroIfNull(valueForKey("blendFuncSource", dictionary)));
                    m_tBlendFunc.dst = int.Parse(ChangeToZeroIfNull(valueForKey("blendFuncDestination", dictionary)));

                    // color
                    m_tStartColor.r = float.Parse(ChangeToZeroIfNull(valueForKey("startColorRed", dictionary)));
                    m_tStartColor.g = float.Parse(ChangeToZeroIfNull(valueForKey("startColorGreen", dictionary)));
                    m_tStartColor.b = float.Parse(ChangeToZeroIfNull(valueForKey("startColorBlue", dictionary)));
                    m_tStartColor.a = float.Parse(ChangeToZeroIfNull(valueForKey("startColorAlpha", dictionary)));

                    m_tStartColorVar.r = float.Parse(ChangeToZeroIfNull(valueForKey("startColorVarianceRed", dictionary)));
                    m_tStartColorVar.g = float.Parse(ChangeToZeroIfNull(valueForKey("startColorVarianceGreen", dictionary)));
                    m_tStartColorVar.b = float.Parse(ChangeToZeroIfNull(valueForKey("startColorVarianceBlue", dictionary)));
                    m_tStartColorVar.a = float.Parse(ChangeToZeroIfNull(valueForKey("startColorVarianceAlpha", dictionary)));

                    m_tEndColor.r = float.Parse(ChangeToZeroIfNull(valueForKey("finishColorRed", dictionary)));
                    m_tEndColor.g = float.Parse(ChangeToZeroIfNull(valueForKey("finishColorGreen", dictionary)));
                    m_tEndColor.b = float.Parse(ChangeToZeroIfNull(valueForKey("finishColorBlue", dictionary)));
                    m_tEndColor.a = float.Parse(ChangeToZeroIfNull(valueForKey("finishColorAlpha", dictionary)));

                    m_tEndColorVar.r = float.Parse(ChangeToZeroIfNull(valueForKey("finishColorVarianceRed", dictionary)));
                    m_tEndColorVar.g = float.Parse(ChangeToZeroIfNull(valueForKey("finishColorVarianceGreen", dictionary)));
                    m_tEndColorVar.b = float.Parse(ChangeToZeroIfNull(valueForKey("finishColorVarianceBlue", dictionary)));
                    m_tEndColorVar.a = float.Parse(ChangeToZeroIfNull(valueForKey("finishColorVarianceAlpha", dictionary)));

                    // particle size
                    m_fStartSize = float.Parse(ChangeToZeroIfNull(valueForKey("startParticleSize", dictionary)));
                    m_fStartSizeVar = float.Parse(ChangeToZeroIfNull(valueForKey("startParticleSizeVariance", dictionary)));
                    m_fEndSize = float.Parse(ChangeToZeroIfNull(valueForKey("finishParticleSize", dictionary)));
                    m_fEndSizeVar = float.Parse(ChangeToZeroIfNull(valueForKey("finishParticleSizeVariance", dictionary)));

                    // position
                    float x = float.Parse(ChangeToZeroIfNull(valueForKey("sourcePositionx", dictionary)));
                    float y = float.Parse(ChangeToZeroIfNull(valueForKey("sourcePositiony", dictionary)));
                    this.position = new CCPoint(x,y);
                    m_tPosVar.x = float.Parse(ChangeToZeroIfNull(valueForKey("sourcePositionVariancex", dictionary)));
                    m_tPosVar.y = float.Parse(ChangeToZeroIfNull(valueForKey("sourcePositionVariancey", dictionary)));

                    // Spinning
                    m_fStartSpin = float.Parse(ChangeToZeroIfNull(valueForKey("rotationStart", dictionary)));
                    m_fStartSpinVar = float.Parse(ChangeToZeroIfNull(valueForKey("rotationStartVariance", dictionary)));
                    m_fEndSpin= float.Parse(ChangeToZeroIfNull(valueForKey("rotationEnd", dictionary)));
                    m_fEndSpinVar= float.Parse(ChangeToZeroIfNull(valueForKey("rotationEndVariance", dictionary)));

                    m_nEmitterMode = int.Parse(ChangeToZeroIfNull(valueForKey("emitterType", dictionary)));

                    // Mode A: Gravity + tangential accel + radial accel
                    if( m_nEmitterMode == (int)eParticleMode.kCCParticleModeGravity )
                    {
                        // gravity
                        modeA.gravity.x = float.Parse(ChangeToZeroIfNull(valueForKey("gravityx", dictionary)));
                        modeA.gravity.y = float.Parse(ChangeToZeroIfNull(valueForKey("gravityy", dictionary)));

                        // speed
                        modeA.speed = float.Parse(ChangeToZeroIfNull(valueForKey("speed", dictionary)));
                        modeA.speedVar = float.Parse(ChangeToZeroIfNull(valueForKey("speedVariance", dictionary)));

                        string pszTmp;
                        // radial acceleration
                        pszTmp = valueForKey("radialAcceleration", dictionary);
                        modeA.radialAccel = (pszTmp != null) ? float.Parse(ChangeToZeroIfNull(pszTmp)) : 0;

                        pszTmp = valueForKey("radialAccelVariance", dictionary);
                        modeA.radialAccelVar = (pszTmp != null) ? float.Parse(ChangeToZeroIfNull(pszTmp)) : 0;

                        // tangential acceleration
                        pszTmp = valueForKey("tangentialAcceleration", dictionary);
                        modeA.tangentialAccel = (pszTmp != null) ? float.Parse(ChangeToZeroIfNull(pszTmp)) : 0;

                        pszTmp = valueForKey("tangentialAccelVariance", dictionary);
                        modeA.tangentialAccelVar = (pszTmp != null) ? float.Parse(ChangeToZeroIfNull(pszTmp)) : 0;
                    }

                    // or Mode B: radius movement
                    else if( m_nEmitterMode == (int)eParticleMode.kCCParticleModeRadius )
                    {
                        modeB.startRadius = float.Parse(ChangeToZeroIfNull(valueForKey("maxRadius", dictionary)));
                        modeB.startRadiusVar = float.Parse(ChangeToZeroIfNull(valueForKey("maxRadiusVariance", dictionary)));
                        modeB.endRadius = float.Parse(ChangeToZeroIfNull(valueForKey("minRadius", dictionary)));
                        modeB.endRadiusVar = 0;
                        modeB.rotatePerSecond = float.Parse(ChangeToZeroIfNull(valueForKey("rotatePerSecond", dictionary)));
                        modeB.rotatePerSecondVar = float.Parse(ChangeToZeroIfNull(valueForKey("rotatePerSecondVariance", dictionary)));

                    } else {
                        Debug.Assert(false, "Invalid emitterType in config file");
                        break;
                    }

                    // life span
                    m_fLife = float.Parse(ChangeToZeroIfNull(valueForKey("particleLifespan", dictionary)));
                    m_fLifeVar = float.Parse(ChangeToZeroIfNull(valueForKey("particleLifespanVariance", dictionary)));

                    // emission Rate
                    m_fEmissionRate = m_uTotalParticles / m_fLife;

                    // texture
                    // Try to get the texture from the cache
                    string textureName = valueForKey("textureFileName", dictionary);
                    string fullpath = CCFileUtils.fullPathFromRelativeFile(textureName, m_sPlistFile);

                    CCTexture2D tex = null;

                    if (textureName.Length > 0)
                    {
                        // set not pop-up message box when load image failed
                        bool bNotify = CCFileUtils.IsPopupNotify;
                        CCFileUtils.IsPopupNotify = false;
                        tex = CCTextureCache.sharedTextureCache().addImage(fullpath);

                        // reset the value of UIImage notify
                        CCFileUtils.IsPopupNotify = bNotify;
                    }

                    if (null != tex)
                    {
                        m_pTexture = tex;
                    }
                    else
                    {
                        throw new NotImplementedException();

                    //    string textureData = valueForKey("textureImageData", dictionary);
                    //    Debug.Assert(textureData != null);

                    //    int dataLen = textureData.Length;
                    //    if (dataLen != 0)
                    //    {
                    //        // if it fails, try to get it from the base64-gzipped data
                    //        int decodeLen = base64Decode(textureData, (uint)dataLen, buffer);
                    //        Debug.Assert(buffer != null, "CCParticleSystem: error decoding textureImageData");
                    //        if (buffer == null)
                    //            break;

                    //        int deflatedLen = ZipUtils.ccInflateMemory(buffer, decodeLen, &deflated);
                    //        Debug.Assert(deflated != null, "CCParticleSystem: error ungzipping textureImageData");
                    //        if (deflated == null)
                    //            break;

                    //        image = new CCTexture2D();
                    //        bool isOK = image.initWithImageData(deflated, deflatedLen);
                    //        Debug.Assert(isOK, "CCParticleSystem: error init image with Data");
                    //        if (!isOK)
                    //            break;

                    //        m_pTexture = CCTextureCache.sharedTextureCache().addUIImage(image, fullpath);
                    //    }
                    }
                    Debug.Assert(m_pTexture != null, "CCParticleSystem: error loading the texture");

                    if(m_pTexture == null)
                        break;
                    bRet = true;
                }
            } while (false);
            return bRet;
        }
Beispiel #28
0
 public void ReloadMyTexture(CCTexture2D t)
 {
     if (m_pTextureRefNames.ContainsKey(t))
     {
         string file = m_pTextureRefNames[t];
         AddImage(file);
     }
 }
        /** Sets a new texture with a rect. The rect is in Points.
	    @since v0.99.4
	    */
	    public void setTextureWithRect(CCTexture2D texture, CCRect rect)
        {
            // Only update the texture if is different from the current one
	        if( null == this.Texture || texture.Name != this.Texture.Name )
	        {
		        base.Texture = texture;
	        }

	        initTexCoordsWithRect(rect);
        }
Beispiel #30
0
        public void RemoveTexture(CCTexture2D texture)
        {
            if (texture == null)
            {
                return;
            }

            string key = null;

            foreach (var pair in m_pTextures)
            {
                if (pair.Value == texture)
                {
                    key = pair.Key;
                    break;
                }
            }

            if (key != null)
            {
                m_pTextures.Remove(key);
            }
        }