###前提・実現したいこと
Xamarin Forms + CocosSharpでゲームを作っています。
Xamarin開発者サイトにあるサンプル通りに実装しても、
ViewCreatedに設定したメソッドが実行されません。
実行されたかどうかは各所にSystem.Diagnotstics.Debug.WriteLine
を記述し、ログが出力されたかどうかで判定しています。
なぜかViewCreatedに指定したところのログが出力されません。
###該当のソースコード
using System; using System.Diagnostics; using Xamarin.Forms; using CocosSharp; namespace CocosTest { public class GamePage : ContentPage { 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."); } void LoadGame(object sender, EventArgs e) { Debug.WriteLine("LoadGame"); } } }
###試したこと
ViewCreatedの設定を、CocosSharpView
をnewしたタイミングではなくそのあとに行ってみましたが、ダメでした。
var gameView = new CocosSharpView() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, DesignResolution = new Size(1024, 768), BackgroundColor = Color.Aqua }; gameView.ViewCreated += (sender, e) => { Debug.WriteLine("ViewCreated"); };
###補足情報(言語/FW/ツール等のバージョンなど)
- OS : Mac OS 10.11.6
- Xamarin Studio : Xamarin Studio Community 6.1.2
- Xamarin Forms : 2.3.3.175
- CocosSharp.Forms : 1.7.1
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/12/12 01:29
2016/12/12 06:35