Exemplo n.º 1
0
        private void InitBug1159Layer()
        {
            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            CCLayerColor background = new CCLayerColor(new CCColor4B(255, 0, 255, 255));

            AddChild(background);

            CCLayerColor sprite_a = new CCLayerColor(new CCColor4B(255, 0, 0, 255));

            sprite_a.AnchorPoint = new CCPoint(0.5f, 0.5f);
            sprite_a.IgnoreAnchorPointForPosition = true;
            sprite_a.Position = new CCPoint(0.0f, s.Height / 2);
            AddChild(sprite_a);

            sprite_a.RunAction(new CCRepeatForever((CCFiniteTimeAction) new CCSequence(
                                                       new CCMoveTo(1.0f, new CCPoint(1024.0f, 384.0f)),
                                                       new CCMoveTo(1.0f, new CCPoint(0.0f, 384.0f)))));

            CCLayerColor sprite_b = new CCLayerColor(new CCColor4B(0, 0, 255, 255));

            sprite_b.AnchorPoint = new CCPoint(0.5f, 0.5f);
            sprite_b.IgnoreAnchorPointForPosition = true;
            sprite_b.Position = new CCPoint(s.Width / 2, s.Height / 2);
            AddChild(sprite_b);

            CCMenuItemLabelTTF label = new CCMenuItemLabelTTF(new CCLabelTtf("Flip Me", "Helvetica", 24), callBack);
            CCMenu             menu  = new CCMenu(label);

            menu.Position = new CCPoint(s.Width - 200.0f, 50.0f);
            AddChild(menu);
        }
Exemplo n.º 2
0
        public TestScene()
            : base(AppDelegate.SharedWindow)
        {
            contentLayer = new CCLayer();
            AddChild(contentLayer, MENU_LEVEL);

            //add the menu item for back to main menu
            var label = new CCLabelTtf("MainMenu", "arial", 30);

            pMenuItem = new CCMenuItemLabelTTF(label, MainMenuCallback);

            pMenu = new CCMenu(pMenuItem);

            pMenu.Name = "MainMenu";
            contentLayer.AddChild(pMenu, MENU_LEVEL);
        }
Exemplo n.º 3
0
        public CocosDenshionTest()
        {
            testMenu = null;
            beginPos = new CCPoint(0, 0);
            soundId  = 0;

            string[] testItems =
            {
                "Play background music",
                "Stop background music",
                "Pause background music",
                "Resume background music",
                "Rewind background music",
                "Is background music playing",
                "Play effect",
                "Play effect repeatly",
                "Stop effect",
                "Unload effect",
                "Add background music volume",
                "Sub background music volume",
                "Add effects volume",
                "Sub effects volume"
            };

            testMenu      = new CCMenu(null);
            testMenuItems = new List <CCMenuItem>();

            for (int i = 0; i < testItems.Count(); ++i)
            {
                CCLabelTtf         label    = new CCLabelTtf(testItems[i], "arial", 24);
                CCMenuItemLabelTTF menuItem = new CCMenuItemLabelTTF(label, MenuCallback);
                testMenu.AddChild(menuItem, i + 10000);
                testMenuItems.Add(menuItem);
            }

            AddChild(testMenu);

            // preload background music and effect
            CCSimpleAudioEngine.SharedEngine.PreloadBackgroundMusic(CCFileUtils.FullPathFromRelativePath(MUSIC_FILE));
            CCSimpleAudioEngine.SharedEngine.PreloadEffect(CCFileUtils.FullPathFromRelativePath(EFFECT_FILE));

            // set default volume
            CCSimpleAudioEngine.SharedEngine.EffectsVolume         = 0.5f;
            CCSimpleAudioEngine.SharedEngine.BackgroundMusicVolume = 0.5f;
        }
Exemplo n.º 4
0
        public LayerGradient()
        {
            gradientLayer = new CCLayerGradient(new CCColor4B(255, 0, 0, 255), new CCColor4B(0, 255, 0, 255), new CCPoint(0.9f, 0.9f));

            AddChild(gradientLayer, 0, kTagLayer);

            // Register Touch Event
            var touchListener = new CCEventListenerTouchAllAtOnce();

            touchListener.OnTouchesMoved = onTouchesMoved;
            AddEventListener(touchListener);

            CCLabelTtf         label1 = new CCLabelTtf("Compressed Interpolation: Enabled", "arial", 26);
            CCLabelTtf         label2 = new CCLabelTtf("Compressed Interpolation: Disabled", "arial", 26);
            CCMenuItemLabelTTF item1  = new CCMenuItemLabelTTF(label1);
            CCMenuItemLabelTTF item2  = new CCMenuItemLabelTTF(label2);
            CCMenuItemToggle   item   = new CCMenuItemToggle((toggleItem), item1, item2);

            menu = new CCMenu(item);
            AddChild(menu);
        }
Exemplo n.º 5
0
        public TestController()
        {
            // Add close menu
            closeMenuItem = new CCMenuItemImage(TestResource.s_pPathClose, TestResource.s_pPathClose, CloseCallback);
            closeMenu     = new CCMenu(closeMenuItem);

            CCMenuItemFont.FontName = "MarkerFelt";
            CCMenuItemFont.FontSize = 22;


            #if !PSM && !WINDOWS_PHONE
            #if NETFX_CORE
            versionLabel = new CCLabelTtf("v" + this.GetType().GetAssemblyName().Version.ToString(), "arial", 30);
            #else
            versionLabel = new CCLabelTtf("v" + this.GetType().Assembly.GetName().Version.ToString(), "arial", 30);
            #endif
            AddChild(versionLabel, 20000);
            #endif

            // Add test list menu
            testListMenu = new CCMenu();
            for (int i = 0; i < (int)(TestCases.TESTS_COUNT); ++i)
            {
                CCLabelTtf label    = new CCLabelTtf(Tests.g_aTestNames[i], "arial", 50);
                CCMenuItem menuItem = new CCMenuItemLabelTTF(label, MenuCallback);

                testListMenu.AddChild(menuItem, i + MENU_ITEM_Z_ORDER);
                testListMenuItems.Add(menuItem);
            }

            #if XBOX || OUYA
            CCSprite sprite = new CCSprite("Images/aButton");
            AddChild(sprite, 10001);
            menuIndicator = sprite;
            #endif

            AddChild(testListMenu);
            AddChild(closeMenu, 1);
        }
Exemplo n.º 6
0
        protected override void AddedToScene()
        {
            base.AddedToScene();

            //Our information layer it's on parent layer because our information text are statics
            background          = new CCSprite("Background.png");
            background.Position = windowSize.Center;
            background.Scale    = windowSize.Height / background.Texture.ContentSizeInPixels.Height;
            BackgroundLayer.AddChild(background, -3);
            this.Position = windowSize.Center;

            //Creation menu debug options
            var lbl1 = new CCMenuItemLabelTTF(GetDefaultFontTtf("Shapes"), (o) => { debug_shapes = !debug_shapes; RefreshDebug(); });

            lbl1.AnchorPoint = new CCPoint(0, .5f);
            var lbl2 = new CCMenuItemLabelTTF(GetDefaultFontTtf("Joins"), (o) => { debug_joints = !debug_joints; RefreshDebug(); });

            lbl2.AnchorPoint = new CCPoint(0, .5f);
            var lbl3 = new CCMenuItemLabelTTF(GetDefaultFontTtf("Contact"), (o) => { debug_contacts = !debug_contacts; RefreshDebug(); });

            lbl3.AnchorPoint = new CCPoint(0, .5f);
            var lbl4 = new CCMenuItemLabelTTF(GetDefaultFontTtf("BB"), (o) => { debug_bb = !debug_bb; RefreshDebug(); });

            lbl4.AnchorPoint = new CCPoint(0, .5f);
            CCMenu menu = new CCMenu(new CCMenuItem[] { lbl1, lbl2, lbl3, lbl4 });

            menu.AlignItemsVertically();
            menu.Position = new CCPoint(windowSize.Width * .02f, windowSize.Height * .35f);
            InformationLayer.AddChild(menu);

            background_white          = new CCSprite("Background-alone.png");
            background_white.Position = windowSize.Center;
            background_white.Scale    = windowSize.Height / background_white.Texture.ContentSizeInPixels.Height;
            background_white.Visible  = false;
            InformationLayer.AddChild(background_white, -4);

            logo = new LogoNode();
            logo.InitialPosition = new CCPoint(new CCPoint(windowSize.Width * .90f, windowSize.Height * .05f));
            logo.Position        = new CCPoint(logo.InitialPosition);

            InformationLayer.AddChild(logo, -2);

            logo.RunAction(new CCRepeatForever(
                               new CCEaseSineInOut(new CCMoveBy(1.5f, new CCPoint(0, 10))),
                               new CCEaseSineInOut(new CCMoveBy(1.5f, new CCPoint(0, -10))))
                           );

            //Debug draw initialization
            //m_debugDraw = new CCChipmunkDebugDraw(DEFAULT_FULL_FONT);

            //Space initialization
            space = new cpSpace();
            //space.SetDebugDraw(m_debugDraw);

            space.CollisionEnabled = CollisionEnabled;
            m_debugDraw            = new PhysicsDebugDraw(space);
            CollisionEnabled
            AddChild(m_debugDraw);

            RefreshDebug();

            //Title initialization
            example             = GetDefaultFontTtf("Physics examples");
            example.AnchorPoint = new CCPoint(.5f, 1f);
            //example.Scale = .3f;
            InformationLayer.AddChild(example);
            SetTitle(this.GetType().Name);

            //Player initialization
            menuLayerPlayer             = GetPlayerLayer();
            menuLayerPlayer.AnchorPoint = new CCPoint(0, 0);

            menuLayerPlayer.Position = new CCPoint(Window.WindowSizeInPixels.Width * .12f, Window.WindowSizeInPixels.Height * .05f);
            InformationLayer.AddChild(menuLayerPlayer);

            //Listeners initializations
            //eMouse = new CCEventListenerMouse();
            //eMouse.OnMouseMove += OnMouseMove;
            //eMouse.OnMouseDown += OnMouseDown;
            //eMouse.OnMouseUp += OnMouseUp;
            //eMouse.OnMouseScroll = e => CCMouse.Instance.OnMouseScroll(e, this);
            //AddEventListener(eMouse);

            eTouch = new CCEventListenerTouchAllAtOnce();
            eTouch.OnTouchesBegan     += OnTouchesBegan;
            eTouch.OnTouchesMoved     += OnTouchesMoved;
            eTouch.OnTouchesCancelled += OnTouchesCancelled;
            eTouch.OnTouchesEnded     += OnTouchesEnded;
            AddEventListener(eTouch);
        }