Ejemplo n.º 1
0
        public AnimationModel()
        {
            var cocosSharpView = new CocosSharpView();

            cocosSharpView.ViewCreated += (sender, e) =>
            {
                var gameView             = sender as CCGameView;
                var cocosSharpViewWidth  = cocosSharpView.Width;
                var cocosSharpViewHeight = cocosSharpView.Height;
                gameView.DesignResolution = new CCSizeI((int)cocosSharpViewWidth, (int)cocosSharpViewHeight);
                var scene = new CCScene(gameView);
                var layer = new CCLayerColor(CCColor4B.White);

                hito       = new CCSprite("hito.png", null);
                hito.Scale = 0.5f;

                firstPositionX = 0 - (hito.ContentSize.Width / 2);
                firstPositionY = (float)cocosSharpViewHeight / 2;
                hito.PositionX = firstPositionX;
                hito.PositionY = firstPositionY;
                distance       = (float)cocosSharpViewWidth + hito.ContentSize.Width;

                layer.AddChild(hito);
                scene.AddLayer(layer);
                gameView.RunWithScene(scene);
            };
            Content = cocosSharpView;
        }
        void CreateTopHalf(Grid grid)
        {
            stackLayoutMap = new StackLayout();

            var image = new Image
            {
                Source            = ImageSource.FromResource("Xamarin.Forms_EFCore.movement.png"),
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.Start,
                HeightRequest     = 30
            };

            var tapGestureRecognizer = new TapGestureRecognizer();

            tapGestureRecognizer.Tapped += (s, e) => {
                MoveToMovement();
            };
            image.GestureRecognizers.Add(tapGestureRecognizer);

            var gameView = new CocosSharpView()
            {
                // Notice it has the same properties as other XamarinForms Views
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                // This gets called after CocosSharp starts up:
                ViewCreated = HandleViewCreated
            };

            // We'll add it to the top half (row 0)
            stackLayoutMap.Children.Add(image);
            stackLayoutMap.Children.Add(gameView);
            grid.Children.Add(stackLayoutMap, 0, 0);
        }
Ejemplo n.º 3
0
        public MainPage()
        {
            InitializeComponent();

            var cocossharpView = new CocosSharpView();

            cocossharpView.ViewCreated = (sender, e) =>
            {
                var ccgameView = sender as CCGameView;
                var scene      = new CCScene(ccgameView);

                accelerometer         = new CCAccelerometer(ccgameView);
                accelerometer.Enabled = true;

                var listener = new CCEventListenerAccelerometer();
                listener.OnAccelerate = DidAccelerate;
                scene.AddEventListener(listener);

                var callBack = new TimerCallback((o) => { accelerometer.Update(); });
                timer = new Timer(callBack, null, Timeout.Infinite, Timeout.Infinite);
                ccgameView.RunWithScene(scene);
            };
            MyGrid.Children.Add(cocossharpView, 0, 0);

            StartButton.Clicked += (sender, e) => timer.Change(0, 1000);
            StopButton.Clicked  += (sender, e) => timer.Change(Timeout.Infinite, Timeout.Infinite);
        }
Ejemplo n.º 4
0
        public GamePage()
        {
            var grid = new Grid();

            grid.RowDefinitions = new RowDefinitionCollection {
                new RowDefinition {
                    Height = new GridLength(1, GridUnitType.Star)
                },
                new RowDefinition {
                    Height = new GridLength(1, GridUnitType.Star)
                }
            };
            var gameView = new CocosSharpView()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                DesignResolution  = new Size(1024, 768),
                BackgroundColor   = Color.Aqua,
                ViewCreated       = LoadGame
            };

            grid.Children.Add(gameView);

            Content = grid;

            Debug.WriteLine("GamePage init.");
        }
Ejemplo n.º 5
0
 public PlayPage()
 {
     Title       = "Play";
     _formsGameV = new CocosSharpView {
         ViewCreated = LoadGame
     };
     Content = _formsGameV;
 }
Ejemplo n.º 6
0
 protected override void OnAppearing()
 {
     base.OnAppearing();
     Content = new CocosSharpView()
     {
         // MemoryLeak1
         ViewCreated = HandleViewCreated,
     };
 }
Ejemplo n.º 7
0
        public ParticlesView()
        {
            var sharpView = new CocosSharpView
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                ViewCreated       = HandleViewCreated
            };

            Content = sharpView;
        }
Ejemplo n.º 8
0
        void CreateTopHalf(Grid grid)
        {
            var gameView = new CocosSharpView()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                ViewCreated       = HandleViewCreated
            };

            grid.Children.Add(gameView, 0, 0);
        }
Ejemplo n.º 9
0
        /*
         * Création de la gameview
         */
        private void CreateGameView(AbsoluteLayout GameLayout)
        {
            var gameView = new CocosSharpView()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                ViewCreated       = HandleViewCreated
            };

            GameLayout.Children.Add(gameView);
        }
Ejemplo n.º 10
0
 public Drawing()
 {
     InitializeComponent ();
     gameView = new CocosSharpView () {
         HorizontalOptions = LayoutOptions.FillAndExpand,
         VerticalOptions = LayoutOptions.FillAndExpand,
         DesignResolution = App.screenSize,
         ViewCreated = LoadGame
     };
     Content = gameView;
 }
Ejemplo n.º 11
0
        public GameView()
        {
            //create a new view
            var sharpView = new CocosSharpView
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                ViewCreated       = HandleViewCreated
            };

            Content = sharpView;
        }
Ejemplo n.º 12
0
        //GameLayer gameLayer;


        public GamePage(INavigationService navigationService)
        {
            //Device.OnPlatform(iOS: () => Padding = new Thickness(0, 20, 0, 0)
            //   , Android: () => Padding = new Thickness(0, 0, 0, 0)
            //   , WinPhone: () => Padding = new Thickness(0, 0, 0, 0));

            NavigationPage.SetHasNavigationBar(this, false);
            _navigationService = navigationService;

            Grid layout = new Grid {
                Padding = 0, ColumnSpacing = 0, Margin = 0, RowSpacing = 0
            };

            layout.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });
            layout.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Auto)
            });

            //addView.IsVisible = false;

            gameView = new CocosSharpView()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                // Set the game world dimensions

                DesignResolution = navigationService.DesignResolution,
                ResolutionPolicy = CocosSharpView.ViewResolutionPolicy.ExactFit,
                // Set the method to call once the view has been initialised
                ViewCreated = LoadGame
            };

            //Random random = new Random();
            //StackLayout layout = new StackLayout();
            //layout.Padding = 10;
            //Label label = new Label();
            //label.Text = random.Next(1000, 9999).ToString();
            //layout.Children.Add(label);
            //layout.Children.Add(gameView);

            layout.Children.Add(gameView, 0, 0);

            if (!AreAdsRemoved((Plugin.InAppBilling.Abstractions.PurchaseState)PurchaseStatus))
            {
                var addView = new Controls.AdView();
                layout.Children.Add(addView, 0, 1);
            }

            Content = layout;
        }
Ejemplo n.º 13
0
 public GamePage()
 {
     gameView = new CocosSharpView()
     {
         HorizontalOptions = LayoutOptions.FillAndExpand,
         VerticalOptions   = LayoutOptions.FillAndExpand,
         // Set the game world dimensions
         DesignResolution = new Size(App.Width, App.Height),
         // Set the method to call once the view has been initialised
         ViewCreated = LoadGame
     };
     Content = gameView;
 }
Ejemplo n.º 14
0
		void CreateTopHalf(Grid grid)
		{
			// This hosts our game view. 
			var gameView = new CocosSharpView () {
				// Notice it has the same properties as other XamarinForms Views
				HorizontalOptions = LayoutOptions.FillAndExpand,
				VerticalOptions = LayoutOptions.FillAndExpand,
				// This gets called after CocosSharp starts up:
						ViewCreated = HandleViewCreated
			};
			// We'll add it to the top half (row 0)
			grid.Children.Add (gameView, 0, 0);
		}
Ejemplo n.º 15
0
		public GamePage ()
		{
			gameView = new CocosSharpView () {
				HorizontalOptions = LayoutOptions.FillAndExpand,
				VerticalOptions = LayoutOptions.FillAndExpand,
				// Set the game world dimensions
				DesignResolution = new Size (1024, 768),
				// Set the method to call once the view has been initialised
				ViewCreated = LoadGame
			};

			Content = gameView;
		}
Ejemplo n.º 16
0
        public GamePage()
        {
            InitializeComponent();

            var gameView = new CocosSharpView()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                ViewCreated       = HandleViewCreated
            };

            mainLayout.Children.Add(gameView);
        }
Ejemplo n.º 17
0
        void CreateTopHalf(Grid grid)
        {
            var gameView = new CocosSharpView()
            {
                // Notice it has the same properties as other XamarinForms Views
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                // This gets called after CocosSharp starts up:
                ViewCreated = HandleViewCreated
            };

            // We'll add it to the top half (row 0)
            grid.Children.Add(gameView, 0, 0);
        }
Ejemplo n.º 18
0
        /**********************************************************************
         *********************************************************************/
        void CreateTopHalf(Grid grid)
        {
            var gameView = new CocosSharpView()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                BackgroundColor   = Color.White, /*Android bug: Doesn't work for Android*/
                // This gets called after CocosSharp starts up:
                ViewCreated = HandleViewCreated
            };

            gameView.ResolutionPolicy = CocosSharpView.ViewResolutionPolicy.ExactFit; //gameview fits the screen
            grid.Children.Add(gameView, 0, 0);
        }
Ejemplo n.º 19
0
        void CreateNewGameView()
        {
            _gameView = new CocosSharpView()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                // Set the game world dimensions
                //DesignResolution = new Size(1024, 768),
                // Set the method to call once the view has been initialised
                ViewCreated = LoadGame
            };

            Content = _gameView;
        }
Ejemplo n.º 20
0
        public MainLayer()
        {
            var Flex     = new StackLayout();
            var gameView = new CocosSharpView()
            {  // Notice it has the same properties as other XamarinForms Views
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                // This gets called after CocosSharp starts up:
                ViewCreated = HandleViewCreated
            };

            Flex.Children.Add(gameView);
            Content = Flex;
            NavigationPage.SetHasNavigationBar(this, false);
        }
Ejemplo n.º 21
0
 public MainPage(App myApp)
 {
     this.myApp = myApp;
     // set the global variable
     Instance = this;
     gameView = new CocosSharpView()
     {
         // Notice it has the same properties as other XamarinForms Views
         HorizontalOptions = LayoutOptions.FillAndExpand,
         VerticalOptions   = LayoutOptions.FillAndExpand,
         // This gets called after CocosSharp starts up:
         ViewCreated = HandleViewCreated
     };
     this.Content = gameView;
 }
Ejemplo n.º 22
0
        private void CreateTopHalf(Grid grid)
        {
            // questo ospita la nostra vista di gioco
            var gameView = new CocosSharpView()
            {
                /* ha le stesse proprietà di altre visualizzazioni XamarinForms
                 * questo è chiamato dopo CocosSharp avviato */
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                ViewCreated       = HandleViewCreated
            };

            // lo aggiungeremo alla metà superiore (riga 0)
            grid.Children.Add(gameView, 0, 0);
        }
Ejemplo n.º 23
0
        void CreateView(StackLayout layout)
        {
            // This hosts our game view.
            var gameView = new CocosSharpView()
            {
                // Notice it has the same properties as other XamarinForms Views
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                // This gets called after CocosSharp starts up:
                ViewCreated = HandleViewCreated
            };

            // We'll add it to the top half (row 0)
            layout.Children.Add(gameView);
        }
        public MainPage()
        {
            InitializeComponent();

            var grid = this.FindByName <Grid>("MainGrid");

            var gameView = new CocosSharpView()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                ViewCreated       = CocosSharpView_ViewCreated
            };

            grid.Children.Add(gameView, 0, 0);
        }
Ejemplo n.º 25
0
        public GamePage()
        {
            width  = DependencyService.Get <IDisplay>().Width;
            height = DependencyService.Get <IDisplay>().Height;

            gameView = new CocosSharpView()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                DesignResolution  = new Size(width, height),
                ResolutionPolicy  = CocosSharpView.ViewResolutionPolicy.ExactFit,
                ViewCreated       = LoadGame
            };

            Content = gameView;
        }
Ejemplo n.º 26
0
        public GamePage()
        {
            gameView = new CocosSharpView()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                // Set the game world dimensions

                DesignResolution = new Size(768, 1280),
                //ResolutionPolicy = CocosSharpView.ViewResolutionPolicy.ShowAll,
                // Set the method to call once the view has been initialised

                ViewCreated = LoadGame
            };

            Content = gameView;
        }
Ejemplo n.º 27
0
        public GamePage()
        {
            Title = "Puzzles";
            BackgroundColor = BackgroundColor = Color.Silver;
            this.gameView = new CocosSharpView()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.Fill,
                // BUG: this needs to be initialized.
                // Otherwise ContentSize of page will be negative.
                DesignResolution = new Size(1, 1),
                ViewCreated = LoadGame
            };

            ToolbarSetup();
            ControlsSetup();
            RegisterMessages();
        }
Ejemplo n.º 28
0
        public GamePage()
        {
            Title           = "Puzzles";
            BackgroundColor = BackgroundColor = Color.Silver;
            this.gameView   = new CocosSharpView()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.Fill,
                // BUG: this needs to be initialized.
                // Otherwise ContentSize of page will be negative.
                DesignResolution = new Size(1, 1),
                ViewCreated      = LoadGame
            };

            ToolbarSetup();
            ControlsSetup();
            RegisterMessages();
        }
        public GamePage()
        {
            listView = new ListView () {
                ItemsSource = "These are some words I want to display in a list".Split (new[] { ' ' }),
            };
            gameView = new CocosSharpView () {
                // Set the game world dimensions
                DesignResolution = new Size (1024, 768),
                // Set the method to call once the view has been initialised
                ViewCreated = LoadGame
            };
            mainAbsoluteLayout = new AbsoluteLayout () {
                Children = {
                    listView,
                    gameView,
                },
            };

            Content = mainAbsoluteLayout;
        }
Ejemplo n.º 30
0
        public MainPage()
        {
            InitializeComponent();

            var grid = this.FindByName <Grid>("MainGrid");

            var gameView = new CocosSharpView()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                ViewCreated       = GameDelegate.LoadGame
            };

            grid.Children.Add(gameView, 0, 0);

            KeepShooting.Layers.Title.NavigateToWebViewCommand = new Command(async(uri) =>
            {
                await Navigation.PushAsync(new CreditContentPage(uri as string));
            });
        }
Ejemplo n.º 31
0
        private void AddPoint(float x, float y)
        {
            _x = x; _y = y;

            var gameView = new CocosSharpView()
            {
                // Notice it has the same properties as other XamarinForms Views
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                // This gets called after CocosSharp starts up:
                ViewCreated = HandleViewCreatedPoints
            };

            // We'll add it to the top half (row 0)
            try
            {
                homeVisual.Children.Clear();
                homeVisual.Children.Add(gameView);
            }catch (Exception e)
            {
            }
        }
Ejemplo n.º 32
0
        /**********************************************************************
         *********************************************************************/
        async void CreateTopHalf(Grid grid)
        {
            scrollView = new ScrollView();
            scrollView.VerticalOptions = LayoutOptions.FillAndExpand;
            gameView = new CocosSharpView()
            {
                BackgroundColor = App._viewBackground,
                // This gets called after CocosSharp starts up:
                ViewCreated = HandleViewCreated
            };
            //Debug.WriteLine("gv: " + gameView.WidthRequest + ", " + gameView.HeightRequest);
            //Debug.WriteLine("Dr: " + gameView.DesignResolution); //1.333333
            //Debug.WriteLine("app: " + Application.Current.MainPage.Width + ", " + Application.Current.MainPage.Height);
            //Debug.WriteLine("Model: " + DeviceInfo.Name);

            /*
             * gameView.ResolutionPolicy = CocosSharpView.ViewResolutionPolicy.ShowAll;
             * gameView.DesignResolution = new Size(400.0, 2000.0);
             * gameView.HeightRequest = 2000.0;
             */



            //NOTOK
            //414, 736 iPhone 8 Plus
            //375, 812 iPhone 11 Pro
            //414, 896 iPhone 11 Pro Max
            //390, 844 iPhone 12 Pro
            //428, 926 iPhone 12 Pro Max
            //375, 812 iPhone 12 mini
            if (DeviceInfo.Name == "iPhone 11 Pro Max" ||
                DeviceInfo.Name == "iPhone 11 Pro" ||
                DeviceInfo.Name == "iPhone 12" ||
                DeviceInfo.Name == "iPhone 12 Pro Max" ||
                DeviceInfo.Name == "iPhone 12 Pro" ||
                DeviceInfo.Name == "iPhone 12 mini" ||
                DeviceInfo.Name == "iPhone 8 Plus")

            {
                gameView.ResolutionPolicy = CocosSharpView.ViewResolutionPolicy.ShowAll;
                gameView.HeightRequest    = Application.Current.MainPage.Height * 1.4;
                gameView.DesignResolution = new Size(400.0, 2000.0);
                gameView.ScaleXTo(1.4);
            }
            //if someone names their iPhone differently
            else if (Device.Idiom == TargetIdiom.Phone &&
                     Device.RuntimePlatform == Device.iOS &&
                     DeviceInfo.Name.StartsWith("iPhone") == false &&
                     DeviceInfo.Name.StartsWith("iPod") == false)
            {
                gameView.ResolutionPolicy = CocosSharpView.ViewResolutionPolicy.ShowAll;
                gameView.HeightRequest    = Application.Current.MainPage.Height * 1.4;
                gameView.DesignResolution = new Size(400.0, 2000.0);
                gameView.ScaleXTo(1.4);
            }
            //OK
            //1024, 1366 iPad Pro (12.9-inch) (5th generation)
            //1024, 1366 iPad Pro (12.9-inch) (4th generation)
            //834, 1194 iPad Pro (11-inch) (3rd generation)
            //834, 1194 iPad Pro (11-inch) (2nd generation)
            //768, 1024 iPad Pro (9.7-inch)
            //820, 1180 iPad Air (4th generation)
            //810, 1080 iPad
            //OK
            //320, 568 iPod touch (7th generation)
            //375, 667 iPhone SE (2nd generation)
            //375, 667 iPhone 8
            //414, 896 iPhone 11
            else
            {
                gameView.ResolutionPolicy = CocosSharpView.ViewResolutionPolicy.ShowAll;
                gameView.DesignResolution = new Size(400.0, 2000.0);
                gameView.HeightRequest    = 2000.0;
            }


            grid.Children.Add(scrollView, 0, 0);
            scrollView.Content = gameView;
            await scrollView.ScrollToAsync(gameView, ScrollToPosition.End, true);
        }