public override void DidFinishLaunching(NSNotification notification) { // Start the progress indicator animation. loadingProgressIndicator.StartAnimation(this); gameLogo.Image = new NSImage(NSBundle.MainBundle.PathForResource("logo", "png")); archerButton.Image = new NSImage(NSBundle.MainBundle.PathForResource("button_archer", "png")); warriorButton.Image = new NSImage(NSBundle.MainBundle.PathForResource("button_warrior", "png")); // The size for the primary scene - 1024x768 is good for OS X and iOS. var size = new CGSize(1024, 768); // Load the shared assets of the scene before we initialize and load it. scene = new AdventureScene(size); scene.LoadSceneAssetsWithCompletionHandler(() => { scene.Initialize(); scene.ScaleMode = SKSceneScaleMode.AspectFill; SKView.PresentScene(scene); loadingProgressIndicator.StopAnimation(this); loadingProgressIndicator.Hidden = true; NSAnimationContext.CurrentContext.Duration = 2.0f; ((NSButton)archerButton.Animator).AlphaValue = 1.0f; ((NSButton)warriorButton.Animator).AlphaValue = 1.0f; scene.ConfigureGameControllers(); }); SKView.ShowsFPS = true; SKView.ShowsDrawCount = true; SKView.ShowsNodeCount = true; }
public override void ViewDidLoad() { base.ViewDidLoad(); var scene = ShaderScene.Random(3); var skView = new SKView(View.Frame) { ShowsFPS = true, PreferredFramesPerSecond = 120 }; View.AddSubview(skView); skView.PresentScene(scene); }
public override void LoadView() { base.LoadView (); View = skView = new SKView { ShowsFPS = true, ShowsNodeCount = true, Frame = View.Frame, }; var scene = new MyScene (View.Bounds.Size) { ScaleMode = SKSceneScaleMode.AspectFill }; skView.PresentScene (scene); }
public override void LoadView() { base.LoadView(); View = skView = new SKView { ShowsFPS = true, ShowsNodeCount = true, Frame = View.Frame, }; var scene = new MyScene(View.Bounds.Size) { ScaleMode = SKSceneScaleMode.AspectFill }; skView.PresentScene(scene); }
public override void ViewWillLayoutSubviews() { base.ViewWillLayoutSubviews(); // Configure the view SKView skView = (SKView)this.View; if (skView.Scene == null) { // Create and configure the scene SKScene scene = new MyScene(skView.Bounds.Size); scene.ScaleMode = SKSceneScaleMode.AspectFill; // Present the scene skView.PresentScene(scene); } }
void BuildScence() { loadingProgressIndicator.StartAnimating(); CGSize size = View.Bounds.Size; // On iPhone/iPod touch we want to see a similar amount of the scene as on iPad. // So, we set the size of the scene to be double the size of the view, which is // the whole screen, 3.5- or 4- inch. This effectively scales the scene to 50%. if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone) { size.Height *= 2; size.Width *= 2; } scene = new AdventureScene(size); scene.LoadSceneAssetsWithCompletionHandler(() => { scene.Initialize(); scene.ScaleMode = SKSceneScaleMode.AspectFill; scene.ConfigureGameControllers(); loadingProgressIndicator.StopAnimating(); loadingProgressIndicator.Hidden = true; SKView.PresentScene(scene); UIView.Animate(2, 0, UIViewAnimationOptions.CurveEaseInOut, () => { archerButton.Alpha = 1; warriorButton.Alpha = 1; }, null); }); SKView.ShowsFPS = true; SKView.ShowsDrawCount = true; SKView.ShowsNodeCount = true; }
public override void ViewDidLoad() { base.ViewDidLoad(); if (DevModeIsOn) { currentTime = DevLevelTime; } // Configure the view. SKView skView = (SKView)View; skView.ShowsFPS = DevModeIsOn; skView.ShowsNodeCount = DevModeIsOn; /* Sprite Kit applies additional optimizations to improve rendering performance */ skView.IgnoresSiblingOrder = true; // Create and configure the scene. scene = SKNode.FromFile <GameScene>("GameScene"); scene.ScaleMode = SKSceneScaleMode.AspectFill; // Передаем сцене данные о размере вью scene.SetSize(skView.Bounds.Size); // Создаем игровой уровень, передаем его сцене level = new Level(DevModeIsOn); scene.Level = level; // инциализируем делегат обработки обмена местами камешков scene.SwipeHandler = HandleSwipeAsync; // Кнопка "В меню" UIButton stopButton = new UIButton { Frame = new CoreGraphics.CGRect(30, View.Bounds.Size.Height - 100, 120, 45), Font = CommonFont, BackgroundColor = ButtonColor }; stopButton.SetTitle("В МЕНЮ", UIControlState.Normal); stopButton.TouchUpInside += (sender, e) => { gameTimer.Invalidate(); UIViewController mainMenu = Storyboard.InstantiateViewController("MainMenu"); NavigationController.PushViewController(mainMenu, true); }; // Кнопка паузы UIButton pauseButton = new UIButton { Frame = new CoreGraphics.CGRect(skView.Bounds.Size.Width - 150, View.Bounds.Size.Height - 100, 120, 45), Font = CommonFont, BackgroundColor = ButtonColor }; pauseButton.SetTitle("||", UIControlState.Normal); pauseButton.TouchUpInside += (sender, e) => { pauseLabel.Hidden = scene.GameIsPaused; scene.GameIsPaused = !scene.GameIsPaused; scene.SwitchBacgroundZPosition(); }; // получаем лучший счет highScore = GetHighScore(); // лэйбл с лучшим счетом highScoreLabel = new UILabel { Frame = new CoreGraphics.CGRect ( skView.Bounds.Size.Width / 2 - HighScoreLabelWidth / 2, HighScoreLabelY, HighScoreLabelWidth, CommonLabelHeight ), TextAlignment = UITextAlignment.Center, Font = CommonFont, Text = "Лучший счёт: " + highScore, TextColor = UIColor.White }; // лэйбл с таймером timerLabel = new UILabel { Frame = new CoreGraphics.CGRect ( skView.Bounds.Size.Width / 2 - CommonLabelWidth / 2, TimerLabelY, CommonLabelWidth, CommonLabelHeight ), Font = CommonFont, TextAlignment = UITextAlignment.Center, TextColor = UIColor.White }; // лэйбл с надписью Счет UILabel scoreTitle = new UILabel { Frame = new CoreGraphics.CGRect ( skView.Bounds.Size.Width / 2 - CommonLabelWidth / 2, ScoreTitleLabelY, CommonLabelWidth, CommonLabelHeight ), TextAlignment = UITextAlignment.Center, Font = CommonFont, Text = "Счёт:", TextColor = UIColor.White }; // лэйбл со счетом scoreLabel = new UILabel { Frame = new CoreGraphics.CGRect ( skView.Bounds.Size.Width / 2 - CommonLabelWidth / 2, ScoreLabelY, CommonLabelWidth, CommonLabelHeight ), TextAlignment = UITextAlignment.Center, Font = CommonFont, Text = "0", TextColor = UIColor.White }; // лэйбл с надписью Пауза pauseLabel = new UILabel { Hidden = true, Frame = new CoreGraphics.CGRect ( skView.Bounds.Size.Width / 2 - CommonLabelWidth / 2, skView.Bounds.Size.Height / 2 - CommonLabelHeight / 2, CommonLabelWidth, CommonLabelHeight ), TextAlignment = UITextAlignment.Center, Font = CommonFont, Text = "ПАУЗА", TextColor = UIColor.White }; // добавляем элементы интерфейса на вью skView.Add(stopButton); skView.Add(pauseButton); skView.Add(highScoreLabel); skView.Add(timerLabel); skView.Add(scoreTitle); skView.Add(scoreLabel); skView.Add(pauseLabel); // Present the scene. skView.PresentScene(scene); // Начало игры BeginGame(); }