Пример #1
0
        public void set2DProjection()
        {
            CCSize winSize = CCDirector.sharedDirector().winSizeInPixels;

            //glLoadIdentity();

            // set view port for user FBO, fixed bug #543 #544
            //glViewport((GLsizei)0, (GLsizei)0, (GLsizei)winSize.width, (GLsizei)winSize.height);
            //glMatrixMode(GL_PROJECTION);
            //glLoadIdentity();
            //ccglOrtho(0, winSize.width, 0, winSize.height, -1024, 1024);
            //glMatrixMode(GL_MODELVIEW);
        }
Пример #2
0
        public virtual bool init()
        {
            bool       flag       = false;
            CCDirector cCDirector = CCDirector.sharedDirector();

            if (cCDirector != null)
            {
                this.contentSize               = cCDirector.getWinSize();
                this.m_bIsTouchEnabled         = false;
                this.m_bIsAccelerometerEnabled = false;
                flag = true;
            }
            return(flag);
        }
Пример #3
0
 public bool initWithString(string label, string fontName, float fontSize, Microsoft.Xna.Framework.Color fgColor, Microsoft.Xna.Framework.Color bgColor)
 {
     if (!base.init())
     {
         return(false);
     }
     this.m_tDimensions = new CCSize(0f, 0f);
     this.m_pFontName   = fontName;
     this.m_fFontSize   = fontSize * CCDirector.sharedDirector().ContentScaleFactor;
     this.m_fgColor     = fgColor;
     this.m_bgColor     = bgColor;
     this.setString(label);
     return(true);
 }
Пример #4
0
        public virtual bool onTextFieldInsertText(CCTextFieldTTF pSender, string text, int nLen)
        {
            // if insert enter, treat as default to detach with ime
            if ("\n" == text)
            {
                return(false);
            }

            // if the textfield's char count more than m_nCharLimit, doesn't insert text anymore.
            if (pSender.CharCount >= m_nCharLimit)
            {
                return(true);
            }

            // create a insert text sprite and do some action
            CCLabelTTF label = CCLabelTTF.labelWithString(text, TextInputTestScene.FONT_NAME, TextInputTestScene.FONT_SIZE);

            this.addChild(label);
            ccColor3B color = new ccColor3B {
                r = 226, g = 121, b = 7
            };

            label.Color = color;

            // move the sprite from top to position
            CCPoint endPos = pSender.position;

            if (pSender.CharCount > 0)
            {
                endPos.x += pSender.contentSize.width / 2;
            }
            CCSize  inputTextSize = label.contentSize;
            CCPoint beginPos      = new CCPoint(endPos.x, CCDirector.sharedDirector().getWinSize().height - inputTextSize.height * 2);

            float duration = 0.5f;

            label.position = beginPos;
            label.scale    = 8;

            CCAction seq = CCSequence.actions(
                CCSpawn.actions(
                    CCMoveTo.actionWithDuration(duration, endPos),
                    CCScaleTo.actionWithDuration(duration, 1),
                    CCFadeOut.actionWithDuration(duration)),
                CCCallFuncN.actionWithTarget(this, callbackRemoveNodeWhenDidAction));

            label.runAction(seq);
            return(false);
        }
Пример #5
0
        public bool initWithTarget(CCNode followedNode)
        {
            Debug.Assert(followedNode != null);

            m_pobFollowedNode       = followedNode;
            m_bBoundarySet          = false;
            m_bBoundaryFullyCovered = false;

            CCSize winSize = CCDirector.sharedDirector().getWinSize();

            m_obFullScreenSize = new CCPoint(winSize.width, winSize.height);
            m_obHalfScreenSize = CCPointExtension.ccpMult(m_obFullScreenSize, 0.5f);

            return(true);
        }
Пример #6
0
        public static void ccDrawLine(CCPoint origin, CCPoint destination, ccColor4F color)
        {
            float contentScaleFactor = CCDirector.sharedDirector().ContentScaleFactor;

            VertexPositionColor[] vertexPositionColor = new VertexPositionColor[] { new VertexPositionColor(new Vector3(origin.x * contentScaleFactor, origin.y * contentScaleFactor, 0f), new Color(color.r, color.g, color.b, color.a)), new VertexPositionColor(new Vector3(destination.x * contentScaleFactor, destination.y * contentScaleFactor, 0f), new Color(color.r, color.g, color.b, color.a)) };
            CCApplication         cCApplication       = CCApplication.sharedApplication();

            cCApplication.basicEffect.TextureEnabled     = false;
            cCApplication.basicEffect.VertexColorEnabled = true;
            foreach (EffectPass pass in cCApplication.basicEffect.CurrentTechnique.Passes)
            {
                pass.Apply();
                cCApplication.GraphicsDevice.DrawUserPrimitives <VertexPositionColor>(PrimitiveType.LineList, vertexPositionColor, 0, 1);
            }
        }
Пример #7
0
        /// <summary>
        /// initializes the CCLabelTTF with a font name and font size
        /// </summary>
        public bool initWithString(string label, string fontName, float fontSize)
        {
            Debug.Assert(label != null);
            if (base.init())
            {
                m_tDimensions = new CCSize(0, 0);
                m_pFontName   = fontName;

                m_fFontSize = fontSize * CCDirector.sharedDirector().ContentScaleFactor;
                this.setString(label);
                return(true);
            }

            return(false);
        }
Пример #8
0
        public CCPoint convertToNodeSpaceAR(CCPoint worldPoint)
        {
            CCPoint tAnchorPointInPixels;
            CCPoint point = this.convertToNodeSpace(worldPoint);

            if (CCDirector.sharedDirector().ContentScaleFactor == 1f)
            {
                tAnchorPointInPixels = this.m_tAnchorPointInPixels;
            }
            else
            {
                tAnchorPointInPixels = CCPointExtension.ccpMult(this.m_tAnchorPointInPixels, 1f / CCDirector.sharedDirector().ContentScaleFactor);
            }
            return(CCPointExtension.ccpSub(point, tAnchorPointInPixels));
        }
Пример #9
0
        protected void applyLandscape()
        {
            CCDirector cCDirector = CCDirector.sharedDirector();
            CCSize     cCSize     = cCDirector.displaySizeInPixels;
            float      single     = cCSize.width / 2f;
            float      single1    = cCSize.height / 2f;

            switch (cCDirector.deviceOrientation)
            {
            default:
            {
                return;
            }
            }
        }
        /// <summary>
        /// draws a cubic bezier path
        /// @since v0.8
        /// </summary>
        public static void ccDrawCubicBezier(CCPoint origin, CCPoint control1, CCPoint control2, CCPoint destination, int segments, ccColor4F color)
        {
            VertexPositionColor[] vertices = new VertexPositionColor[segments + 1];
            float         factor           = CCDirector.sharedDirector().ContentScaleFactor;
            CCApplication app = CCApplication.sharedApplication();

            float t = 0;

            for (int i = 0; i < segments; ++i)
            {
                float x = (float)Math.Pow(1 - t, 3) * origin.x + 3.0f * (float)Math.Pow(1 - t, 2) * t * control1.x + 3.0f * (1 - t) * t * t * control2.x + t * t * t * destination.x;
                float y = (float)Math.Pow(1 - t, 3) * origin.y + 3.0f * (float)Math.Pow(1 - t, 2) * t * control1.y + 3.0f * (1 - t) * t * t * control2.y + t * t * t * destination.y;
                vertices[i]          = new VertexPositionColor();
                vertices[i].Position = new Vector3(x * factor, y * factor, 0);
                vertices[i].Color    = new Color(color.r, color.g, color.b, color.a);
                t += 1.0f / segments;
            }
            vertices[segments] = new VertexPositionColor()
            {
                Color    = new Color(color.r, color.g, color.b, color.a),
                Position = new Vector3(destination.x * factor, destination.y * factor, 0)
            };

            app.basicEffect.TextureEnabled     = false;
            app.basicEffect.VertexColorEnabled = true;
            foreach (var pass in app.basicEffect.CurrentTechnique.Passes)
            {
                pass.Apply();

                app.GraphicsDevice.DrawUserPrimitives <VertexPositionColor>(PrimitiveType.LineStrip, vertices, 0, segments);
            }

            // Default GL states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
            // Needed states: GL_VERTEX_ARRAY,
            // Unneeded states: GL_TEXTURE_2D, GL_TEXTURE_COORD_ARRAY, GL_COLOR_ARRAY
            //glDisable(GL_TEXTURE_2D);
            //glDisableClientState(GL_TEXTURE_COORD_ARRAY);
            //glDisableClientState(GL_COLOR_ARRAY);

            //glVertexPointer(2, GL_FLOAT, 0, vertices);
            //glDrawArrays(GL_LINE_STRIP, 0, (GLsizei)segments + 1);
            //delete[] vertices;

            //// restore default state
            //glEnableClientState(GL_COLOR_ARRAY);
            //glEnableClientState(GL_TEXTURE_COORD_ARRAY);
            //glEnable(GL_TEXTURE_2D);
        }
Пример #11
0
        /// <summary>
        /// initializes a CCMenu with it's items
        /// </summary>
        bool initWithItems(params CCMenuItem[] item)
        {
            if (base.init())
            {
                this.m_bIsTouchEnabled = true;

                // menu in the center of the screen
                CCSize s = CCDirector.sharedDirector().getWinSize();

                this.m_bIsRelativeAnchorPoint = false;
                anchorPoint      = new CCPoint(0.5f, 0.5f);
                this.contentSize = s;

                // XXX: in v0.7, winSize should return the visible size
                // XXX: so the bar calculation should be done there
                CCRect r;
                CCApplication.sharedApplication().statusBarFrame(out r);

                ccDeviceOrientation orientation = CCDirector.sharedDirector().deviceOrientation;
                if (orientation == ccDeviceOrientation.CCDeviceOrientationLandscapeLeft
                    ||
                    orientation == ccDeviceOrientation.CCDeviceOrientationLandscapeRight)
                {
                    s.height -= r.size.width;
                }
                else
                {
                    s.height -= r.size.height;
                }

                position = new CCPoint(s.width / 2, s.height / 2);

                if (item != null)
                {
                    foreach (var menuItem in item)
                    {
                        this.addChild(menuItem);
                    }
                }
                //	[self alignItemsVertically];

                m_pSelectedItem = null;
                m_eState        = tCCMenuState.kCCMenuStateWaiting;
                return(true);
            }

            return(false);
        }
Пример #12
0
        /// <summary>
        /// initializes the CCLabelTTF with a font name, alignment, dimension and font size
        /// </summary>
        public bool initWithString(string label, CCSize dimensions, CCTextAlignment alignment, string fontName, float fontSize)
        {
            Debug.Assert(label != null);
            if (init())
            {
                m_tDimensions = new CCSize(dimensions.width * CCDirector.sharedDirector().ContentScaleFactor, dimensions.height * CCDirector.sharedDirector().ContentScaleFactor);
                m_eAlignment  = alignment;

                m_pFontName = fontName;

                m_fFontSize = fontSize * CCDirector.sharedDirector().ContentScaleFactor;
                this.setString(label);
                return(true);
            }
            return(false);
        }
Пример #13
0
        private void setNewScene(float dt)
        {
            // [self unschedule:_cmd];
            // "_cmd" is a local variable automatically defined in a method
            // that contains the selector for the method
            this.unschedule(this.setNewScene);
            CCDirector director = CCDirector.sharedDirector();

            // Before replacing, save the "send cleanup to scene"
            m_bIsSendCleanupToScene = director.isSendCleanupToScene();
            director.replaceScene(m_pInScene);
            // enable events while transitions
            CCTouchDispatcher.sharedDispatcher().IsDispatchEvents = true;
            // issue #267
            m_pOutScene.visible = true;
        }
Пример #14
0
        public CCPoint convertToWorldSpaceAR(CCPoint nodePoint)
        {
            CCPoint tAnchorPointInPixels;

            if (CCDirector.sharedDirector().ContentScaleFactor == 1f)
            {
                tAnchorPointInPixels = this.m_tAnchorPointInPixels;
            }
            else
            {
                tAnchorPointInPixels = CCPointExtension.ccpMult(this.m_tAnchorPointInPixels, 1f / CCDirector.sharedDirector().ContentScaleFactor);
            }
            CCPoint point2 = CCPointExtension.ccpAdd(nodePoint, tAnchorPointInPixels);

            return(this.convertToWorldSpace(point2));
        }
Пример #15
0
        public override void draw()
        {
            base.draw();
            CCApplication application = CCApplication.sharedApplication();

            CCDirector.sharedDirector().getWinSize();
            bool       flag       = (this.m_sBlendFunc.src != ccMacros.CC_BLEND_SRC) || (this.m_sBlendFunc.dst != ccMacros.CC_BLEND_DST);
            BlendState blendState = application.GraphicsDevice.BlendState;

            if (flag)
            {
                BlendState state = new BlendState
                {
                    ColorSourceBlend      = OGLES.GetXNABlend(this.m_sBlendFunc.src),
                    AlphaSourceBlend      = OGLES.GetXNABlend(this.m_sBlendFunc.src),
                    ColorDestinationBlend = OGLES.GetXNABlend(this.m_sBlendFunc.dst),
                    AlphaDestinationBlend = OGLES.GetXNABlend(this.m_sBlendFunc.dst)
                };
                application.GraphicsDevice.BlendState = state;
            }
            if (this.Texture != null)
            {
                application.basicEffect.Texture            = this.Texture.getTexture2D();
                application.basicEffect.TextureEnabled     = true;
                application.basicEffect.Alpha              = ((float)this.Opacity) / 255f;
                application.basicEffect.VertexColorEnabled = true;
            }
            VertexPositionColorTexture[] vertexData = this.m_sQuad.getVertices(ccDirectorProjection.kCCDirectorProjection3D);
            short[] indexData = this.m_sQuad.getIndexes(ccDirectorProjection.kCCDirectorProjection3D);
            foreach (EffectPass pass in application.basicEffect.CurrentTechnique.Passes)
            {
                pass.Apply();
                application.GraphicsDevice.DrawUserIndexedPrimitives <VertexPositionColorTexture>(PrimitiveType.TriangleList, vertexData, 0, 4, indexData, 0, 2);
            }
            application.basicEffect.VertexColorEnabled = false;
            if (flag)
            {
                BlendState state2 = new BlendState
                {
                    ColorSourceBlend      = OGLES.GetXNABlend(ccMacros.CC_BLEND_SRC),
                    AlphaSourceBlend      = OGLES.GetXNABlend(ccMacros.CC_BLEND_SRC),
                    ColorDestinationBlend = OGLES.GetXNABlend(ccMacros.CC_BLEND_DST),
                    AlphaDestinationBlend = OGLES.GetXNABlend(ccMacros.CC_BLEND_DST)
                };
                application.GraphicsDevice.BlendState = state2;
            }
        }
Пример #16
0
        public bool initWithSize(ccGridSize gridSize)
        {
            CCSize cCSize = CCDirector.sharedDirector().winSizeInPixels;
            ulong  num    = this.ccNextPOT((ulong)((uint)cCSize.width));
            ulong  num1   = this.ccNextPOT((ulong)((uint)cCSize.height));
            CCTexture2DPixelFormat cCTexture2DPixelFormat = CCTexture2DPixelFormat.kCCTexture2DPixelFormat_RGBA8888;
            CCTexture2D            cCTexture2D            = new CCTexture2D();

            cCTexture2D.initWithData(null, cCTexture2DPixelFormat, (uint)num, (uint)num1, cCSize);
            if (cCTexture2D == null)
            {
                CCLog.Log("cocos2d: CCGrid: error creating texture");
                return(false);
            }
            this.initWithSize(gridSize, cCTexture2D, false);
            return(true);
        }
Пример #17
0
        public override bool initWithTotalParticles(uint numberOfParticles)
        {
            if (!base.initWithTotalParticles(numberOfParticles))
            {
                return(false);
            }
            base.Duration                 = -1f;
            base.EmitterMode              = 0;
            this.modeA.gravity            = new CCPoint(10f, -10f);
            this.modeA.radialAccel        = 0f;
            this.modeA.radialAccelVar     = 1f;
            this.modeA.tangentialAccel    = 0f;
            this.modeA.tangentialAccelVar = 1f;
            this.modeA.speed              = 130f;
            this.modeA.speedVar           = 30f;
            base.Angle    = -90f;
            base.AngleVar = 5f;
            CCSize winSize = CCDirector.sharedDirector().getWinSize();

            this.position        = new CCPoint(winSize.width / 2f, winSize.height);
            this.PosVar          = new CCPoint(winSize.width / 2f, 0f);
            base.Life            = 4.5f;
            base.LifeVar         = 0f;
            base.StartSize       = 4f;
            base.StartSizeVar    = 2f;
            base.EndSize         = -1f;
            base.EmissionRate    = 20f;
            base.StartColor.r    = 0.7f;
            base.StartColor.g    = 0.8f;
            base.StartColor.b    = 1f;
            base.StartColor.a    = 1f;
            base.StartColorVar.r = 0f;
            base.StartColorVar.g = 0f;
            base.StartColorVar.b = 0f;
            base.StartColorVar.a = 0f;
            base.EndColor.r      = 0.7f;
            base.EndColor.g      = 0.8f;
            base.EndColor.b      = 1f;
            base.EndColor.a      = 0.5f;
            base.EndColorVar.r   = 0f;
            base.EndColorVar.g   = 0f;
            base.EndColorVar.b   = 0f;
            base.EndColorVar.a   = 0f;
            base.IsBlendAdditive = false;
            return(true);
        }
Пример #18
0
        public void set3DProjection()
        {
            CCSize winSize = CCDirector.sharedDirector().displaySizeInPixels;

            //// set view port for user FBO, fixed bug #543 #544
            //glViewport(0, 0, (GLsizei)winSize.width, (GLsizei)winSize.height);
            //glMatrixMode(GL_PROJECTION);
            //glLoadIdentity();
            //gluPerspective(60, (GLfloat)winSize.width/winSize.height, 0.5f, 1500.0f);

            //glMatrixMode(GL_MODELVIEW);
            //glLoadIdentity();
            //gluLookAt( winSize.width/2, winSize.height/2, CCDirector::sharedDirector()->getZEye(),
            //    winSize.width/2, winSize.height/2, 0,
            //    0.0f, 1.0f, 0.0f
            //    );
        }
Пример #19
0
		public override bool initWithTotalParticles(uint numberOfParticles)
		{
			if (!base.initWithTotalParticles(numberOfParticles))
			{
				return false;
			}
			base.Duration = -1f;
			base.EmitterMode = 0;
			this.modeA.gravity = new CCPoint(0f, 0f);
			this.modeA.speed = 80f;
			this.modeA.speedVar = 10f;
			this.modeA.radialAccel = -60f;
			this.modeA.radialAccelVar = 0f;
			this.modeA.tangentialAccel = 15f;
			this.modeA.tangentialAccelVar = 0f;
			base.Angle = 90f;
			base.AngleVar = 360f;
			CCSize winSize = CCDirector.sharedDirector().getWinSize();
			this.position = new CCPoint(winSize.width / 2f, winSize.height / 2f);
			this.PosVar = new CCPoint(0f, 0f);
			base.Life = 4f;
			base.LifeVar = 1f;
			base.StartSize = 30f;
			base.StartSizeVar = 10f;
			base.EndSize = -1f;
			base.EmissionRate = (float)((float)base.TotalParticles) / base.Life;
			base.StartColor.r = 0.5f;
			base.StartColor.g = 0.5f;
			base.StartColor.b = 0.5f;
			base.StartColor.a = 1f;
			base.StartColorVar.r = 0.5f;
			base.StartColorVar.g = 0.5f;
			base.StartColorVar.b = 0.5f;
			base.StartColorVar.a = 0.5f;
			base.EndColor.r = 0f;
			base.EndColor.g = 0f;
			base.EndColor.b = 0f;
			base.EndColor.a = 1f;
			base.EndColorVar.r = 0f;
			base.EndColorVar.g = 0f;
			base.EndColorVar.b = 0f;
			base.EndColorVar.a = 0f;
			base.IsBlendAdditive = true;
			return true;
		}
Пример #20
0
        public bool init()
        {
            bool bRet = false;

            do
            {
                CCDirector director = CCDirector.sharedDirector();
                if (director == null)
                {
                    break;
                }

                contentSize = director.getWinSize();
                // success
                bRet = true;
            } while (false);
            return(bRet);
        }
Пример #21
0
        public override void draw()
        {
            base.draw();
            CCApplication mCOpacity = CCApplication.sharedApplication();

            CCDirector.sharedDirector().getWinSize();
            mCOpacity.basicEffect.VertexColorEnabled = true;
            mCOpacity.basicEffect.TextureEnabled     = false;
            mCOpacity.basicEffect.Alpha = (float)this.m_cOpacity / 255f;
            VertexElement[]   vertexElement     = new VertexElement[] { new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0), new VertexElement(12, VertexElementFormat.Vector4, VertexElementUsage.Color, 0) };
            VertexDeclaration vertexDeclaration = new VertexDeclaration(vertexElement);

            foreach (EffectPass pass in mCOpacity.basicEffect.CurrentTechnique.Passes)
            {
                pass.Apply();
                mCOpacity.GraphicsDevice.DrawUserPrimitives <VertexPositionColor>(PrimitiveType.TriangleStrip, this.vertices, 0, 2);
            }
            mCOpacity.basicEffect.Alpha = 1f;
        }
Пример #22
0
        public AtlasFastBitmap()
        {
            // Upper Label
            for (int i = 0; i < 100; i++)
            {
                //char str[6] = {0};
                string str;
                //sprintf(str, "-%d-", i);
                str = string.Format("-{0,d}-", i);
                CCLabelBMFont label = CCLabelBMFont.labelWithString(str, "fonts/bitmapFontTest.fnt");
                addChild(label);

                CCSize s = CCDirector.sharedDirector().getWinSize();

                CCPoint p = new CCPoint(ccMacros.CCRANDOM_0_1() * s.width, ccMacros.CCRANDOM_0_1() * s.height);
                label.position    = p;
                label.anchorPoint = new CCPoint(0.5f, 0.5f);
            }
        }
Пример #23
0
        public void drawNumberOfQuads(int n, int start)
        {
            if (n == start)
            {
                return;
            }
            if (this.m_pQuads == null || (int)this.m_pQuads.Length < 1)
            {
                return;
            }
            CCApplication texture2D = CCApplication.sharedApplication();

            CCDirector.sharedDirector().getWinSize();
            texture2D.basicEffect.Texture            = this.Texture.getTexture2D();
            texture2D.basicEffect.TextureEnabled     = true;
            texture2D.GraphicsDevice.BlendState      = BlendState.AlphaBlend;
            texture2D.basicEffect.VertexColorEnabled = true;
            List <VertexPositionColorTexture> vertexPositionColorTextures = new List <VertexPositionColorTexture>();

            short[] numArray = new short[n * 6];
            for (int i = start; i < start + n; i++)
            {
                ccV3F_C4B_T2F_Quad mPQuads = this.m_pQuads[i];
                if (mPQuads != null)
                {
                    vertexPositionColorTextures.AddRange(mPQuads.getVertices(ccDirectorProjection.kCCDirectorProjection3D).ToList <VertexPositionColorTexture>());
                    numArray[i * 6]     = (short)(i * 4);
                    numArray[i * 6 + 1] = (short)(i * 4 + 1);
                    numArray[i * 6 + 2] = (short)(i * 4 + 2);
                    numArray[i * 6 + 3] = (short)(i * 4 + 2);
                    numArray[i * 6 + 4] = (short)(i * 4 + 1);
                    numArray[i * 6 + 5] = (short)(i * 4 + 3);
                }
            }
            VertexElement[]   vertexElement     = new VertexElement[] { new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0), new VertexElement(12, VertexElementFormat.Vector3, VertexElementUsage.Color, 0), new VertexElement(24, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0) };
            VertexDeclaration vertexDeclaration = new VertexDeclaration(vertexElement);

            foreach (EffectPass pass in texture2D.basicEffect.CurrentTechnique.Passes)
            {
                pass.Apply();
                texture2D.GraphicsDevice.DrawUserIndexedPrimitives <VertexPositionColorTexture>(PrimitiveType.TriangleList, vertexPositionColorTextures.ToArray(), 0, vertexPositionColorTextures.Count, numArray, 0, vertexPositionColorTextures.Count / 2);
            }
        }
Пример #24
0
        public override void onEnter()
        {
            base.onEnter();
            ccColor4B       _ccColor4B = new ccColor4B(0, 0, 0, 0);
            CCSize          winSize    = CCDirector.sharedDirector().getWinSize();
            CCLayer         cCLayer    = new CCLayer();
            CCRenderTexture cCPoint    = CCRenderTexture.renderTextureWithWidthAndHeight((int)winSize.width, (int)winSize.height);

            if (cCPoint == null)
            {
                return;
            }
            cCPoint.Sprite.anchorPoint = new CCPoint(0.5f, 0.5f);
            cCPoint.position           = new CCPoint(winSize.width / 2f, winSize.height / 2f);
            cCPoint.anchorPoint        = new CCPoint(0.5f, 0.5f);
            cCPoint.begin();
            this.m_pInScene.visit();
            cCPoint.end();
            CCRenderTexture cCRenderTexture = CCRenderTexture.renderTextureWithWidthAndHeight((int)winSize.width, (int)winSize.height);

            cCRenderTexture.Sprite.anchorPoint = new CCPoint(0.5f, 0.5f);
            cCRenderTexture.position           = new CCPoint(winSize.width / 2f, winSize.height / 2f);
            cCRenderTexture.anchorPoint        = new CCPoint(0.5f, 0.5f);
            cCRenderTexture.begin();
            this.m_pOutScene.visit();
            cCRenderTexture.end();
            ccBlendFunc _ccBlendFunc  = new ccBlendFunc(1, 1);
            ccBlendFunc _ccBlendFunc1 = new ccBlendFunc(770, 771);

            cCPoint.Sprite.BlendFunc         = _ccBlendFunc;
            cCRenderTexture.Sprite.BlendFunc = _ccBlendFunc1;
            cCLayer.addChild(cCPoint);
            cCLayer.addChild(cCRenderTexture);
            cCPoint.Sprite.Opacity         = 255;
            cCRenderTexture.Sprite.Opacity = 255;
            CCFiniteTimeAction[] cCFiniteTimeActionArray = new CCFiniteTimeAction[] { CCFadeTo.actionWithDuration(this.m_fDuration, 0), CCCallFunc.actionWithTarget(this, new SEL_CallFunc(this.hideOutShowIn)), CCCallFunc.actionWithTarget(this, new SEL_CallFunc(this.finish)) };
            CCAction             cCAction = CCSequence.actions(cCFiniteTimeActionArray);

            cCRenderTexture.Sprite.runAction(cCAction);
            this.addChild(cCLayer, 2, 2147483647);
        }
Пример #25
0
        public virtual bool init()
        {
            bool bRet = false;

            do
            {
                CCDirector director = CCDirector.sharedDirector();
                if (director == null)
                {
                    break;
                }

                contentSize               = director.getWinSize();
                m_bIsTouchEnabled         = false;
                m_bIsAccelerometerEnabled = false;

                bRet = true;
            } while (false);

            return(bRet);
        }
Пример #26
0
        public override void onEnter()
        {
            base.onEnter();
            CCSize s      = CCDirector.sharedDirector().getWinSize();
            float  aspect = s.width / s.height;
            int    x      = (int)(12 * aspect);
            int    y      = 12;

            CCTurnOffTiles     toff   = CCTurnOffTiles.actionWithSize(new ccGridSize(x, y), m_fDuration);
            CCFiniteTimeAction action = easeActionWithAction(toff);

            m_pOutScene.runAction
            (
                CCSequence.actions
                (
                    action,
                    CCCallFunc.actionWithTarget(this, (base.finish)),
                    CCStopGrid.action()
                )
            );
        }
Пример #27
0
        public Atlas6()
        {
            CCSize s = CCDirector.sharedDirector().getWinSize();

            CCLabelBMFont label = null;

            label = CCLabelBMFont.labelWithString("FaFeFiFoFu", "fonts/bitmapFontTest5.fnt");
            addChild(label);
            label.position    = new CCPoint(s.width / 2, s.height / 2 + 50);
            label.anchorPoint = new CCPoint(0.5f, 0.5f);

            label = CCLabelBMFont.labelWithString("fafefifofu", "fonts/bitmapFontTest5.fnt");
            addChild(label);
            label.position    = new CCPoint(s.width / 2, s.height / 2);
            label.anchorPoint = new CCPoint(0.5f, 0.5f);

            label = CCLabelBMFont.labelWithString("aeiou", "fonts/bitmapFontTest5.fnt");
            addChild(label);
            label.position    = new CCPoint(s.width / 2, s.height / 2 - 50);
            label.anchorPoint = new CCPoint(0.5f, 0.5f);
        }
Пример #28
0
        public override void onEnter()
        {
            base.onEnter();

            CCSize s      = CCDirector.sharedDirector().getWinSize();
            float  aspect = s.width / s.height;
            int    x      = (int)(12 * aspect);
            int    y      = 12;

            CCActionInterval action = actionWithSize(new ccGridSize(x, y));

            m_pOutScene.runAction
            (
                CCSequence.actions
                (
                    easeActionWithAction(action),
                    CCCallFunc.actionWithTarget(this, base.finish),
                    CCStopGrid.action()
                )
            );
        }
Пример #29
0
        protected void showFPS()
        {
            CCDirector mUFrames = this;

            mUFrames.m_uFrames = mUFrames.m_uFrames + 1;
            CCDirector mFAccumDt = this;

            mFAccumDt.m_fAccumDt = mFAccumDt.m_fAccumDt + this.m_fDeltaTime;
            if (this.m_fAccumDt > ccMacros.CC_DIRECTOR_FPS_INTERVAL)
            {
                this.m_fFrameRate = (float)((float)this.m_uFrames) / this.m_fAccumDt;
                this.m_uFrames    = 0;
                this.m_fAccumDt   = 0f;
                this.m_pszFPS     = string.Format("{0}", this.m_fFrameRate);
            }
            SpriteFont spriteFont = CCApplication.sharedApplication().content.Load <SpriteFont>("fonts/Arial");

            CCApplication.sharedApplication().spriteBatch.Begin();
            CCApplication.sharedApplication().spriteBatch.DrawString(spriteFont, this.m_pszFPS, new Vector2(0f, CCApplication.sharedApplication().getSize().height - 50f), new Color(0, 255, 255));
            CCApplication.sharedApplication().spriteBatch.End();
        }
Пример #30
0
        public BitmapFontMultiLine()
        {
            CCSize s;

            // Left
            CCLabelBMFont label1 = CCLabelBMFont.labelWithString("Multi line\nLeft", "fonts/bitmapFontTest3.fnt");

            label1.anchorPoint = new CCPoint(0, 0);
            addChild(label1, 0, (int)TagSprite.kTagBitmapAtlas1);

            s = label1.contentSize;

            //CCLOG("content size: %.2fx%.2f", s.width, s.height);
            CCLog.Log("content size: {0,0:2f}x{1,0:2f}", s.width, s.height);


            // Center
            CCLabelBMFont label2 = CCLabelBMFont.labelWithString("Multi line\nCenter", "fonts/bitmapFontTest3.fnt");

            label2.anchorPoint = new CCPoint(0.5f, 0.5f);
            addChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2);

            s = label2.contentSize;
            //CCLOG("content size: %.2fx%.2f", s.width, s.height);
            CCLog.Log("content size: {0,0:2f}x{1,0:2f}", s.width, s.height);

            // right
            CCLabelBMFont label3 = CCLabelBMFont.labelWithString("Multi line\nRight\nThree lines Three", "fonts/bitmapFontTest3.fnt");

            label3.anchorPoint = new CCPoint(1, 1);
            addChild(label3, 0, (int)TagSprite.kTagBitmapAtlas3);

            s = label3.contentSize;
            //CCLOG("content size: %.2fx%.2f", s.width, s.height);

            s = CCDirector.sharedDirector().getWinSize();
            label1.position = new CCPoint();
            label2.position = new CCPoint(s.width / 2, s.height / 2);
            label3.position = new CCPoint(s.width, s.height);
        }