コード例 #1
0
        public LabelAtlasColorTest()
        {
            CCLabelAtlas label1 = new CCLabelAtlas("123 Test", "fonts/tuffy_bold_italic-charmap.png", 48, 64, ' ');

            AddChild(label1, 0, (int)TagSprite.kTagSprite1);
            label1.Position = new CCPoint(10, 100);
            label1.Opacity  = 200;

            CCLabelAtlas label2 = new CCLabelAtlas("0123456789", "fonts/tuffy_bold_italic-charmap.png", 48, 64, ' ');

            AddChild(label2, 0, (int)TagSprite.kTagSprite2);
            label2.Position = new CCPoint(10, 200);
            //label2.setColor( ccRED );
            label2.Color = ccRED;

            CCActionInterval fade = new CCFadeOut(1.0f);
            //CCActionInterval fade_in = fade.reverse();
            CCActionInterval   fade_in = null;
            CCFiniteTimeAction seq     = CCSequence.FromActions(fade, fade_in, null);
            CCAction           repeat  = new CCRepeatForever((CCActionInterval)seq);

            label2.RunAction(repeat);

            m_time = 0;

            //schedule( schedule_selector(LabelAtlasColorTest.step) ); //:@selector(step:)];
        }
コード例 #2
0
        public LabelsEmpty()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            // CCLabelBMFont
            CCLabelBMFont label1 = new CCLabelBMFont("", "fonts/bitmapFontTest3.fnt");

            AddChild(label1, 0, (int)TagSprite.kTagBitmapAtlas1);
            label1.Position = new CCPoint(s.Width / 2, s.Height - 100);

            // CCLabelTTF
            CCLabelTTF label2 = new CCLabelTTF("", "arial", 24);

            AddChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2);
            label2.Position = new CCPoint(s.Width / 2, s.Height / 2);

            // CCLabelAtlas
            CCLabelAtlas label3 = new CCLabelAtlas("", "fonts/tuffy_bold_italic-charmap", 48, 64, ' ');

            AddChild(label3, 0, (int)TagSprite.kTagBitmapAtlas3);
            label3.Position = new CCPoint(s.Width / 2, 0 + 100);

            base.Schedule(updateStrings, 1.0f);

            setEmpty = false;
        }
コード例 #3
0
        /// <summary>
        /// initializes a menu item from a string and atlas with a target/selector
        /// </summary>
        public bool InitFromString(string value, string charMapFile, int itemWidth, int itemHeight, char startCharMap, ICCSelectorProtocol target,
		                           Action<object> selector)
        {
            // CCAssert( value != NULL && strlen(value) != 0, "value length must be greater than 0");
            var label = new CCLabelAtlas(value, charMapFile, itemWidth, itemHeight, startCharMap);
            base.InitWithLabel(label, selector);
            return true;
        }
コード例 #4
0
        public void CreateStatsLabel()
        {
            CCTexture2D    texture;
            CCTextureCache textureCache = CCTextureCache.SharedTextureCache;

            try
            {
                if (!textureCache.Contains("cc_fps_images"))
                {
                    texture = textureCache.AddImage(CCFPSImage.PngData, "cc_fps_images", SurfaceFormat.Bgra4444);
                }
                else
                {
                    texture = textureCache.TextureForKey("cc_fps_images");
                }

                if (texture == null || (texture.ContentSize.Width == 0 && texture.ContentSize.Height == 0))
                {
                    m_bDisplayStats = false;
                    return;
                }
            }
            catch (Exception)
            {
                // MonoGame may not allow texture.fromstream, so catch this exception here
                // and disable the stats
                m_bDisplayStats = false;
                return;
            }
            float factor = m_obWinSizeInPoints.Height / 320.0f;
            var   pos    = CCDirector.SharedDirector.VisibleOrigin;

            m_pFPSLabel = new CCLabelAtlas();
            m_pFPSLabel.SetIgnoreContentScaleFactor(true);
            m_pFPSLabel.InitWithString("00.0", texture, 12, 32, '.');
            m_pFPSLabel.Scale = factor;

            m_pUpdateTimeLabel = new CCLabelAtlas();
            m_pUpdateTimeLabel.SetIgnoreContentScaleFactor(true);
            m_pUpdateTimeLabel.InitWithString("0.000", texture, 12, 32, '.');
            m_pUpdateTimeLabel.Scale = factor;

            m_pDrawTimeLabel = new CCLabelAtlas();
            m_pDrawTimeLabel.SetIgnoreContentScaleFactor(true);
            m_pDrawTimeLabel.InitWithString("0.000", texture, 12, 32, '.');
            m_pDrawTimeLabel.Scale = factor;

            m_pDrawsLabel = new CCLabelAtlas();
            m_pDrawsLabel.SetIgnoreContentScaleFactor(true);
            m_pDrawsLabel.InitWithString("000", texture, 12, 32, '.');
            m_pDrawsLabel.Scale = factor;

            m_pDrawsLabel.Position      = new CCPoint(0, 51 * factor) + pos;
            m_pUpdateTimeLabel.Position = new CCPoint(0, 34 * factor) + pos;
            m_pDrawTimeLabel.Position   = new CCPoint(0, 17 * factor) + pos;
            m_pFPSLabel.Position        = pos;
        }
コード例 #5
0
        /// <summary>
        /// initializes a menu item from a string and atlas with a target/selector
        /// </summary>
        public bool InitFromString(string value, string charMapFile, int itemWidth, int itemHeight, char startCharMap, ICCSelectorProtocol target,
                                   Action <CCMenuItem> selector)
        {
            // CCAssert( value != NULL && strlen(value) != 0, "value length must be greater than 0");
            var label = new CCLabelAtlas(value, charMapFile, itemWidth, itemHeight, startCharMap);

            base.InitWithLabel(label, selector);
            return(true);
        }
コード例 #6
0
ファイル: LabelAtlasHD.cs プロジェクト: Ratel13/cocos2d-xna
        public LabelAtlasHD()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            // CCLabelBMFont
            CCLabelAtlas label1 = new CCLabelAtlas("TESTING RETINA DISPLAY", "fonts/larabie-16", 10, 20, 'A');
            label1.AnchorPoint = new CCPoint(0.5f, 0.5f);

            AddChild(label1);
            label1.Position = new CCPoint(s.Width / 2, s.Height / 2);
        }
コード例 #7
0
        public LabelAtlasHD()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            // CCLabelBMFont
            CCLabelAtlas label1 = new CCLabelAtlas("TESTING RETINA DISPLAY", "fonts/larabie-16", 10, 20, 'A');

            label1.AnchorPoint = new CCPoint(0.5f, 0.5f);

            AddChild(label1);
            label1.Position = new CCPoint(s.Width / 2, s.Height / 2);
        }
コード例 #8
0
ファイル: LabelAtlasTest.cs プロジェクト: Karunp/cocos2d-xna
        public LabelAtlasTest()
        {
            m_time = 0;

            CCLabelAtlas label1 = new CCLabelAtlas("123 Test", "fonts/tuffy_bold_italic-charmap", 48, 64, ' ');
            AddChild(label1, 0, (int)TagSprite.kTagSprite1);
            label1.Position = new CCPoint(10, 100);
            label1.Opacity = 200;

            CCLabelAtlas label2 = new CCLabelAtlas("0123456789", "fonts/tuffy_bold_italic-charmap", 48, 64, ' ');
            AddChild(label2, 0, (int)TagSprite.kTagSprite2);
            label2.Position = new CCPoint(10, 200);
            label2.Opacity = 32;

            Schedule(step);
        }
コード例 #9
0
        public virtual void step(float dt)
        {
            m_time += dt;
            //char string[12] = {0};
            string stepstring;

            //sprintf(string, "%2.2f Test", m_time);
            stepstring = string.Format("{0,2:f2} Test", m_time);
            //std::string string = std::string::stringWithFormat("%2.2f Test", m_time);
            CCLabelAtlas label1 = (CCLabelAtlas)GetChildByTag((int)TagSprite.kTagSprite1);

            label1.Label = (stepstring);

            CCLabelAtlas label2 = (CCLabelAtlas)GetChildByTag((int)TagSprite.kTagSprite2);

            //sprintf(string, "%d", (int)m_time);
            stepstring   = m_time.ToString();
            label2.Label = (stepstring);
        }
コード例 #10
0
        public LabelAtlasColorTest()
        {
            CCLabelAtlas label1 = new CCLabelAtlas("123 Test", "fonts/tuffy_bold_italic-charmap", 48, 64, ' ');
            AddChild(label1, 0, (int)TagSprite.kTagSprite1);
            label1.Position = new CCPoint(10, 100);
            label1.Opacity = 200;

            CCLabelAtlas label2 = new CCLabelAtlas("0123456789", "fonts/tuffy_bold_italic-charmap", 48, 64, ' ');
            AddChild(label2, 0, (int)TagSprite.kTagSprite2);
            label2.Position = new CCPoint(10, 200);
            label2.Color = ccRED;

            CCActionInterval fade = new CCFadeOut  (1.0f);
            CCFiniteTimeAction fade_in = fade.Reverse();
            CCFiniteTimeAction seq = CCSequence.FromActions(fade, fade_in);
            CCAction repeat = new CCRepeatForever ((CCActionInterval)seq);
            label2.RunAction(repeat);

            m_time = 0;

            Schedule(step); //:@selector(step:)];
        }
コード例 #11
0
        public LabelsEmpty()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            // CCLabelBMFont
            CCLabelBMFont label1 = new CCLabelBMFont("", "fonts/bitmapFontTest3.fnt");
            AddChild(label1, 0, (int)TagSprite.kTagBitmapAtlas1);
            label1.Position = new CCPoint(s.Width / 2, s.Height - 100);

            // CCLabelTTF
            CCLabelTTF label2 = new CCLabelTTF("", "arial", 24);
            AddChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2);
            label2.Position = new CCPoint(s.Width / 2, s.Height / 2);

            // CCLabelAtlas
            CCLabelAtlas label3 = new CCLabelAtlas("", "fonts/tuffy_bold_italic-charmap", 48, 64, ' ');
            AddChild(label3, 0, (int)TagSprite.kTagBitmapAtlas3);
            label3.Position = new CCPoint(s.Width / 2, 0 + 100);

            base.Schedule(updateStrings, 1.0f);

            setEmpty = false;
        }
コード例 #12
0
        public void updateStrings(float dt)
        {
            CCLabelBMFont label1 = (CCLabelBMFont)GetChildByTag((int)TagSprite.kTagBitmapAtlas1);
            CCLabelTTF    label2 = (CCLabelTTF)GetChildByTag((int)TagSprite.kTagBitmapAtlas2);
            CCLabelAtlas  label3 = (CCLabelAtlas)GetChildByTag((int)TagSprite.kTagBitmapAtlas3);

            if (!setEmpty)
            {
                label1.Label = ("not empty");
                label2.Label = ("not empty");
                label3.Label = ("hi");

                setEmpty = true;
            }
            else
            {
                label1.Label = ("");
                label2.Label = ("");
                label3.Label = ("");

                setEmpty = false;
            }
        }
コード例 #13
0
ファイル: CCDirector.cs プロジェクト: netonjm/cocos2d-xna
        public virtual bool Init()
        {
            SetDefaultValues();

            // scenes
            m_pRunningScene = null;
            m_pNextScene = null;

            m_pNotificationNode = null;

            m_dOldAnimationInterval = m_dAnimationInterval = 1.0 / kDefaultFPS;

            // Set default projection (3D)
            m_eProjection = CCDirectorProjection.Default;

            // projection delegate if "Custom" projection is used
            m_pProjectionDelegate = null;

            // FPS
            m_fAccumDt = 0.0f;
            m_pFPSLabel = null;
            m_pUpdateTimeLabel = null;
            m_pDrawTimeLabel = null;
            m_pDrawsLabel = null;
            m_bDisplayStats = false;
            m_uTotalFrames = 0;

            m_pStopwatch = new Stopwatch();

            // paused ?
            m_bPaused = false;

            // purge ?
            m_bPurgeDirecotorInNextLoop = false;

            m_obWinSizeInPoints = CCSize.Zero;

            //m_pobOpenGLView = null;

            m_fContentScaleFactor = 1.0f;

            // scheduler
            m_pScheduler = new CCScheduler();
            // action manager
            m_pActionManager = new CCActionManager();
            m_pScheduler.ScheduleUpdateForTarget(m_pActionManager, CCScheduler.kCCPrioritySystem, false);
            // touchDispatcher
            m_pTouchDispatcher = new CCTouchDispatcher();
            m_pTouchDispatcher.Init();

            // KeypadDispatcher
            m_pKeypadDispatcher = new CCKeypadDispatcher();

			// KeyboardDispatcher
			m_pKeyboardDispatcher = new CCKeyboardDispatcher();

			// Accelerometer
#if !PSM &&!NETFX_CORE
            m_pAccelerometer = new CCAccelerometer();
#endif
            // create autorelease pool
            //CCPoolManager::sharedPoolManager()->push();

            m_NeedsInit = false;
            return true;
        }
コード例 #14
0
ファイル: CCDirector.cs プロジェクト: netonjm/cocos2d-xna
        public void CreateStatsLabel()
        {
            if (m_pFPSLabel == null)
            {
                CCTexture2D texture;
                CCTextureCache textureCache = CCTextureCache.SharedTextureCache;

                try
                {
                    if (!textureCache.Contains("cc_fps_images"))
                    {
                        texture = textureCache.AddImage(CCFPSImage.PngData, "cc_fps_images", SurfaceFormat.Bgra4444);
                    }
                    else
                    {
                        texture = textureCache.TextureForKey("cc_fps_images");
                    }

                    if (texture == null || (texture.ContentSize.Width == 0 && texture.ContentSize.Height == 0))
                    {
                        m_bDisplayStats = false;
                        return;
                    }
                }
                catch (Exception)
                {
                    // MonoGame may not allow texture.fromstream, so catch this exception here
                    // and disable the stats
                    m_bDisplayStats = false;
                    return;
                }

                try
                {
                    m_pFPSLabel = new CCLabelAtlas();
                    m_pFPSLabel.SetIgnoreContentScaleFactor(true);
                    m_pFPSLabel.InitWithString("00.0", texture, 12, 32, '.');

                    m_pUpdateTimeLabel = new CCLabelAtlas();
                    m_pUpdateTimeLabel.SetIgnoreContentScaleFactor(true);
                    m_pUpdateTimeLabel.InitWithString("0.000", texture, 12, 32, '.');

                    m_pDrawTimeLabel = new CCLabelAtlas();
                    m_pDrawTimeLabel.SetIgnoreContentScaleFactor(true);
                    m_pDrawTimeLabel.InitWithString("0.000", texture, 12, 32, '.');

                    m_pDrawsLabel = new CCLabelAtlas();
                    m_pDrawsLabel.SetIgnoreContentScaleFactor(true);
                    m_pDrawsLabel.InitWithString("000", texture, 12, 32, '.');

                    m_pMemoryLabel = new CCLabelAtlas();
                    m_pMemoryLabel.SetIgnoreContentScaleFactor(true);
                    m_pMemoryLabel.InitWithString("0", texture, 12, 32, '.');
                    m_pMemoryLabel.Color = new CCColor3B(0, 0, 255);

                    m_pGCLabel = new CCLabelAtlas();
                    m_pGCLabel.SetIgnoreContentScaleFactor(true);
                    m_pGCLabel.InitWithString("0", texture, 12, 32, '.');
                    m_pGCLabel.Color = new CCColor3B(255, 0, 0);
                }
                catch (Exception ex)
                {
                    m_pFPSLabel = null;
                    m_bDisplayStats = false;
                    CCLog.Log("Failed to create the stats labels.");
                    CCLog.Log(ex.ToString());
                    return;
                }
            }

            float factor = CCDrawManager.DesignResolutionSize.Height / 320.0f;
            var pos = CCDirector.SharedDirector.VisibleOrigin;

            m_pFPSLabel.Scale = factor;
            m_pUpdateTimeLabel.Scale = factor;
            m_pDrawTimeLabel.Scale = factor;
            m_pDrawsLabel.Scale = factor;
            m_pMemoryLabel.Scale = factor;
            m_pGCLabel.Scale = factor;

            m_pMemoryLabel.Position = new CCPoint(0, 85 * factor) + pos;
            m_pGCLabel.Position = new CCPoint(0, 68 * factor) + pos;
            m_pDrawsLabel.Position = new CCPoint(0, 51 * factor) + pos;
            m_pUpdateTimeLabel.Position = new CCPoint(0, 34 * factor) + pos;
            m_pDrawTimeLabel.Position = new CCPoint(0, 17 * factor) + pos;
            m_pFPSLabel.Position = pos;
        }
コード例 #15
0
ファイル: CCDirector.cs プロジェクト: krashman/cocos2d-xna
        public virtual bool Init()
        {
            SetDefaultValues();

            // scenes
            m_pRunningScene = null;
            m_pNextScene    = null;

            m_pNotificationNode = null;

            m_dOldAnimationInterval = m_dAnimationInterval = 1.0 / kDefaultFPS;

            // Set default projection (3D)
            m_eProjection = CCDirectorProjection.Default;

            // projection delegate if "Custom" projection is used
            m_pProjectionDelegate = null;

            // FPS
            m_fAccumDt         = 0.0f;
            m_pFPSLabel        = null;
            m_pUpdateTimeLabel = null;
            m_pDrawTimeLabel   = null;
            m_pDrawsLabel      = null;
            m_bDisplayStats    = false;
            m_uTotalFrames     = 0;

            m_pStopwatch = new Stopwatch();

            // paused ?
            m_bPaused = false;

            // purge ?
            m_bPurgeDirectorInNextLoop = false;

            m_obWinSizeInPoints = CCSize.Zero;

            //m_pobOpenGLView = null;

            m_fContentScaleFactor = 1.0f;

            // scheduler
            m_pScheduler = new CCScheduler();
            // action manager
            m_pActionManager = new CCActionManager();
            m_pScheduler.ScheduleUpdateForTarget(m_pActionManager, CCScheduler.kCCPrioritySystem, false);
            // touchDispatcher
            m_pTouchDispatcher = new CCTouchDispatcher();
            m_pTouchDispatcher.Init();

            // KeypadDispatcher
            m_pKeypadDispatcher = new CCKeypadDispatcher();

            // KeyboardDispatcher
            m_pKeyboardDispatcher = new CCKeyboardDispatcher();

            // Accelerometer
#if !PSM && !NETFX_CORE
            m_pAccelerometer = new CCAccelerometer();
#endif

            m_NeedsInit = false;
            return(true);
        }
コード例 #16
0
ファイル: CCDirector.cs プロジェクト: krashman/cocos2d-xna
        public void CreateStatsLabel()
        {
            if (m_pFPSLabel == null)
            {
                CCTexture2D    texture;
                CCTextureCache textureCache = CCTextureCache.SharedTextureCache;

                try
                {
                    if (!textureCache.Contains("cc_fps_images"))
                    {
                        texture = textureCache.AddImage(CCFPSImage.PngData, "cc_fps_images", SurfaceFormat.Bgra4444);
                    }
                    else
                    {
                        texture = textureCache.TextureForKey("cc_fps_images");
                    }

                    if (texture == null || (texture.ContentSize.Width == 0 && texture.ContentSize.Height == 0))
                    {
                        m_bDisplayStats = false;
                        return;
                    }
                }
                catch (Exception)
                {
                    // MonoGame may not allow texture.fromstream, so catch this exception here
                    // and disable the stats
                    m_bDisplayStats = false;
                    return;
                }

                try
                {
                    m_pFPSLabel = new CCLabelAtlas();
                    m_pFPSLabel.SetIgnoreContentScaleFactor(true);
                    m_pFPSLabel.InitWithString("00.0", texture, 12, 32, '.');

                    m_pUpdateTimeLabel = new CCLabelAtlas();
                    m_pUpdateTimeLabel.SetIgnoreContentScaleFactor(true);
                    m_pUpdateTimeLabel.InitWithString("0.000", texture, 12, 32, '.');

                    m_pDrawTimeLabel = new CCLabelAtlas();
                    m_pDrawTimeLabel.SetIgnoreContentScaleFactor(true);
                    m_pDrawTimeLabel.InitWithString("0.000", texture, 12, 32, '.');

                    m_pDrawsLabel = new CCLabelAtlas();
                    m_pDrawsLabel.SetIgnoreContentScaleFactor(true);
                    m_pDrawsLabel.InitWithString("000", texture, 12, 32, '.');

                    m_pMemoryLabel = new CCLabelAtlas();
                    m_pMemoryLabel.SetIgnoreContentScaleFactor(true);
                    m_pMemoryLabel.InitWithString("0", texture, 12, 32, '.');
                    m_pMemoryLabel.Color = new CCColor3B(0, 0, 255);

                    m_pGCLabel = new CCLabelAtlas();
                    m_pGCLabel.SetIgnoreContentScaleFactor(true);
                    m_pGCLabel.InitWithString("0", texture, 12, 32, '.');
                    m_pGCLabel.Color = new CCColor3B(255, 0, 0);
                }
                catch (Exception ex)
                {
                    m_pFPSLabel     = null;
                    m_bDisplayStats = false;
                    CCLog.Log("Failed to create the stats labels.");
                    CCLog.Log(ex.ToString());
                    return;
                }
            }

            float factor = CCDrawManager.DesignResolutionSize.Height / 320.0f;
            var   pos    = CCDirector.SharedDirector.VisibleOrigin;

            m_pFPSLabel.Scale        = factor;
            m_pUpdateTimeLabel.Scale = factor;
            m_pDrawTimeLabel.Scale   = factor;
            m_pDrawsLabel.Scale      = factor;
            m_pMemoryLabel.Scale     = factor;
            m_pGCLabel.Scale         = factor;

            m_pMemoryLabel.Position     = new CCPoint(0, 85 * factor) + pos;
            m_pGCLabel.Position         = new CCPoint(0, 68 * factor) + pos;
            m_pDrawsLabel.Position      = new CCPoint(0, 51 * factor) + pos;
            m_pUpdateTimeLabel.Position = new CCPoint(0, 34 * factor) + pos;
            m_pDrawTimeLabel.Position   = new CCPoint(0, 17 * factor) + pos;
            m_pFPSLabel.Position        = pos;
        }
コード例 #17
0
ファイル: CCDirector.cs プロジェクト: huaqiangs/cocos2d-xna
        public void CreateStatsLabel()
        {
            CCTexture2D texture;
            CCTextureCache textureCache = CCTextureCache.SharedTextureCache;

            try
            {
                if (!textureCache.Contains("cc_fps_images"))
                {
                    texture = textureCache.AddImage(CCFPSImage.PngData, "cc_fps_images", SurfaceFormat.Bgra4444);
                }
                else
                {
                    texture = textureCache.TextureForKey("cc_fps_images");
                }

                if (texture == null || (texture.ContentSize.Width == 0 && texture.ContentSize.Height == 0))
                {
                    m_bDisplayStats = false;
                    return;
                }
            }
            catch (Exception)
            {
                // MonoGame may not allow texture.fromstream, so catch this exception here
                // and disable the stats
                m_bDisplayStats = false;
                return;
            }
            float factor = m_obWinSizeInPoints.Height / 320.0f;
            var pos = CCDirector.SharedDirector.VisibleOrigin;

            m_pFPSLabel = new CCLabelAtlas();
            m_pFPSLabel.SetIgnoreContentScaleFactor(true);
            m_pFPSLabel.InitWithString("00.0", texture, 12, 32 , '.');
            m_pFPSLabel.Scale = factor;

            m_pUpdateTimeLabel = new CCLabelAtlas();
            m_pUpdateTimeLabel.SetIgnoreContentScaleFactor(true);
            m_pUpdateTimeLabel.InitWithString("0.000", texture, 12, 32, '.');
            m_pUpdateTimeLabel.Scale = factor;

            m_pDrawTimeLabel = new CCLabelAtlas();
            m_pDrawTimeLabel.SetIgnoreContentScaleFactor(true);
            m_pDrawTimeLabel.InitWithString("0.000", texture, 12, 32, '.');
            m_pDrawTimeLabel.Scale = factor;

            m_pDrawsLabel = new CCLabelAtlas();
            m_pDrawsLabel.SetIgnoreContentScaleFactor(true);
            m_pDrawsLabel.InitWithString("000", texture, 12, 32, '.');
            m_pDrawsLabel.Scale = factor;

            m_pDrawsLabel.Position = new CCPoint(0, 51 * factor) + pos;
            m_pUpdateTimeLabel.Position = new CCPoint(0, 34 * factor) + pos;
            m_pDrawTimeLabel.Position = new CCPoint(0, 17 * factor) + pos;
            m_pFPSLabel.Position = pos;
        }
コード例 #18
0
ファイル: ParticleTest.cs プロジェクト: Ratel13/cocos2d-xna
        public ParticleDemo()
        {
            InitWithColor(CCTypes.CreateColor(127, 127, 127, 255));

            m_emitter = null;

            TouchEnabled = true;

            CCSize s = CCDirector.SharedDirector.WinSize;
            CCLabelTTF label = new CCLabelTTF(title(), "arial", 28);
            AddChild(label, 100, kLabelTag);
            label.Position = new CCPoint(s.Width / 2, s.Height - 50);

            CCLabelTTF tapScreen = new CCLabelTTF(subtitle(), "arial", 20);
            tapScreen.Position = new CCPoint(s.Width / 2, s.Height - 80);
            AddChild(tapScreen, 100);

            CCMenuItemImage item1 = new CCMenuItemImage(TestResource.s_pPathB1, TestResource.s_pPathB2, backCallback);
            CCMenuItemImage item2 = new CCMenuItemImage(TestResource.s_pPathR1, TestResource.s_pPathR2, restartCallback);
            CCMenuItemImage item3 = new CCMenuItemImage(TestResource.s_pPathF1, TestResource.s_pPathF2, nextCallback);

            CCMenuItemToggle item4 = new CCMenuItemToggle(toggleCallback,
                                                                     new CCMenuItemFont("Free Movement"),
                                                                     new CCMenuItemFont("Relative Movement"),
                                                                     new CCMenuItemFont("Grouped Movement"));

            CCMenu menu = new CCMenu(item1, item2, item3, item4);

            menu.Position = new CCPoint(0, 0);
            item1.Position = new CCPoint(s.Width / 2 - 100, 30);
            item2.Position = new CCPoint(s.Width / 2, 30);
            item3.Position = new CCPoint(s.Width / 2 + 100, 30);
            item4.Position = new CCPoint(0, 100);
            item4.AnchorPoint = new CCPoint(0, 0);

            AddChild(menu, 100);

            CCLabelAtlas labelAtlas = new CCLabelAtlas("0000", "Images/fps_Images", 12, 32, '.');
            AddChild(labelAtlas, 100, ParticleTestScene.kTagLabelAtlas);
            labelAtlas.Position = new CCPoint(s.Width - 66, 50);

            // moving background
            m_background = new CCSprite(TestResource.s_back3);
            AddChild(m_background, 5);
            m_background.Position = new CCPoint(s.Width / 2, s.Height - 180);

            CCActionInterval move = new CCMoveBy (4, new CCPoint(300, 0));
            CCFiniteTimeAction move_back = move.Reverse();
            CCFiniteTimeAction seq = new CCSequence(move, move_back);
            m_background.RunAction(new CCRepeatForever ((CCActionInterval) seq));

            Schedule(step);
        }
コード例 #19
0
ファイル: MenuLayer1.cs プロジェクト: CartBlanche/cocos2d-xna
        public MenuLayer1()
        {
            CCMenuItemFont.FontSize = 30;
            CCMenuItemFont.FontName = "arial";
            base.TouchEnabled = true;
            // Font Item

            CCSprite spriteNormal = new CCSprite(s_MenuItem, new CCRect(0, 23 * 2, 115, 23));
            CCSprite spriteSelected = new CCSprite(s_MenuItem, new CCRect(0, 23 * 1, 115, 23));
            CCSprite spriteDisabled = new CCSprite(s_MenuItem, new CCRect(0, 23 * 0, 115, 23));

            CCMenuItemSprite item1 = new CCMenuItemSprite(spriteNormal, spriteSelected, spriteDisabled, this.menuCallback);

            // Image Item
            CCMenuItem item2 = new CCMenuItemImage(s_SendScore, s_PressSendScore, this.menuCallback2);

            // Label Item (LabelAtlas)
            CCLabelAtlas labelAtlas = new CCLabelAtlas("0123456789", "Images/fps_Images", 16, 24, '.');
            CCMenuItemLabel item3 = new CCMenuItemLabel(labelAtlas, this.menuCallbackDisabled);
            item3.DisabledColor = new CCColor3B(32, 32, 64);
            item3.Color = new CCColor3B(200, 200, 255);

            // Font Item
            CCMenuItemFont item4 = new CCMenuItemFont("I toggle enable items", this.menuCallbackEnable);

            item4.FontSizeObj = 20;
            item4.FontNameObj = "arial";

            // Label Item (CCLabelBMFont)
            CCLabelBMFont label = new CCLabelBMFont("configuration", "fonts/bitmapFontTest3.fnt");
            CCMenuItemLabel item5 = new CCMenuItemLabel(label, this.menuCallbackConfig);
            

            // Testing issue #500
            item5.Scale = 0.8f;

            // Events
            CCMenuItemFont.FontName = "arial";
            CCMenuItemFont item6 = new CCMenuItemFont("Priority Test", menuCallbackPriorityTest);

            // Font Item
            CCMenuItemFont item7 = new CCMenuItemFont("Quit", this.onQuit);

            CCActionInterval color_action = new CCTintBy (0.5f, 0, -255, -255);
            CCActionInterval color_back = (CCActionInterval)color_action.Reverse();
            CCFiniteTimeAction seq = CCSequence.FromActions(color_action, color_back);
            item7.RunAction(new CCRepeatForever ((CCActionInterval)seq));

            CCMenu menu = new CCMenu(item1, item2, item3, item4, item5, item6, item7);
            menu.AlignItemsVertically();

            // elastic effect
            CCSize s = CCDirector.SharedDirector.WinSize;
            int i = 0;
            CCNode child;
            var pArray = menu.Children;
            object pObject = null;
            if (pArray.Count > 0)
            {
                for (int j = 0; j < pArray.Count; j++)
                {
                    pObject = pArray[j];
                    if (pObject == null)

                        break;
                    child = (CCNode)pObject;
                    CCPoint dstPoint = child.Position;
                    int offset = (int)(s.Width / 2 + 50);
                    if (i % 2 == 0)
                        offset = -offset;

                    child.Position = new CCPoint(dstPoint.X + offset, dstPoint.Y);
                    child.RunAction(new CCEaseElasticOut(new CCMoveBy (2, new CCPoint(dstPoint.X - offset, 0)), 0.35f));
                    i++;

                }
            }
            m_disabledItem = item3;
            m_disabledItem.Enabled = false;

            AddChild(menu);
        }
コード例 #20
0
        public virtual void initWithSubTest(int asubtest, int particles)
        {
            //srandom(0);

            subtestNumber = asubtest;
            CCSize s = CCDirector.SharedDirector.WinSize;

            lastRenderedCount = 0;
            quantityParticles = particles;

            CCMenuItemFont.FontSize = 64;
            CCMenuItemFont decrease = new CCMenuItemFont(" - ", onDecrease);
            decrease.Color = new CCColor3B(0, 200, 20);
            CCMenuItemFont increase = new CCMenuItemFont(" + ", onIncrease);
            increase.Color = new CCColor3B(0, 200, 20);

            CCMenu menu = new CCMenu(decrease, increase);
            menu.AlignItemsHorizontally();
            menu.Position = new CCPoint(s.Width / 2, s.Height / 2 + 15);
            AddChild(menu, 1);

            CCLabelTTF infoLabel = new CCLabelTTF("0 nodes", "Marker Felt", 30);
            infoLabel.Color = new CCColor3B(0, 200, 20);
            infoLabel.Position = new CCPoint(s.Width / 2, s.Height - 90);
            AddChild(infoLabel, 1, PerformanceParticleTest.kTagInfoLayer);

            // particles on stage
            CCLabelAtlas labelAtlas = new CCLabelAtlas("0000", "Images/fps_Images", 16, 24, '.');
            AddChild(labelAtlas, 0, PerformanceParticleTest.kTagLabelAtlas);
            labelAtlas.Position = new CCPoint(s.Width - 66, 50);

            // Next Prev Test
            ParticleMenuLayer pMenu = new ParticleMenuLayer(true, PerformanceParticleTest.TEST_COUNT, PerformanceParticleTest.s_nParCurIdx);
            AddChild(pMenu, 1, PerformanceParticleTest.kTagMenuLayer);

            // Sub Tests
            CCMenuItemFont.FontSize = 38;
            CCMenu pSubMenu = new CCMenu(null);
            for (int i = 1; i <= 6; ++i)
            {
                //char str[10] = {0};
                string str;
                //sprintf(str, "%d ", i);
                str = string.Format("{0:G}", i);
                CCMenuItemFont itemFont = new CCMenuItemFont(str, testNCallback);
                itemFont.Tag = i;
                pSubMenu.AddChild(itemFont, 10);

                if (i <= 3)
                {
                    itemFont.Color = new CCColor3B(200, 20, 20);
                }
                else
                {
                    itemFont.Color = new CCColor3B(0, 200, 20);
                }
            }
            pSubMenu.AlignItemsHorizontally();
            pSubMenu.Position = new CCPoint(s.Width / 2, 80);
            AddChild(pSubMenu, 2);

            CCLabelTTF label = new CCLabelTTF(title(), "arial", 38);
            AddChild(label, 1);
            label.Position = new CCPoint(s.Width / 2, s.Height - 32);
            label.Color = new CCColor3B(255, 255, 40);

            updateQuantityLabel();
            createParticleSystem();

            Schedule(step);
        }