Exemplo n.º 1
0
        /* =============================================================
         * Reference OnTouchesBegan: externally sourced code
         * Purpose: to create touch logic on the sprite buttons in the level select screen
         * Date: 28/10/2018
         * Source: stackoverflow
         * Author: jaybers
         * url: https://stackoverflow.com/questions/33168953/android-game-drag-one-image-at-a-time-into-screen-from-a-group-of-images
         * Adaption required: provide links to each level as per the corresponding button
         * ==============================================================
         */
        bool OnTouchesBegan(CCTouch touch, CCEvent touchEvent)
        {
            CCSprite caller = touchEvent.CurrentTarget as CCSprite;

            currentSpriteTouched = null;
            if (caller == button1)
            {
                if (button1.BoundingBoxTransformedToWorld.ContainsPoint(touch.Location))
                {
                    //System.Diagnostics.Debug.WriteLine("Button pressed");
                    Window.DefaultDirector.ReplaceScene(LevelOne.LvlOneScene(Window));
                    return(true);
                }
                else if (button2.BoundingBoxTransformedToWorld.ContainsPoint(touch.Location))
                {
                    Window.DefaultDirector.ReplaceScene(LevelTwo.LvlTwoScene(Window));
                    return(true);
                }
                else if (button3.BoundingBoxTransformedToParent.ContainsPoint(touch.Location))
                {
                    Window.DefaultDirector.ReplaceScene(LevelThree.LvlThreeScene(Window));
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        //provides a reference to this scene to be used with the Level Select screen
        public static CCScene LvlTwoScene(CCWindow mainWindow)
        {
            var scene = new CCScene(mainWindow);
            var layer = new LevelTwo();

            scene.AddChild(layer);
            return(scene);
        }