public AndroidGameWindow(AndroidGameActivity activity, Game game) { _game = game; Initialize(activity); game.Services.AddService(typeof(View), GameView); }
public static ActivityAttribute GetActivityAttribute(this AndroidGameActivity obj) { var attr = obj.GetType().GetCustomAttributes(typeof(ActivityAttribute), true); if (attr != null) { return((ActivityAttribute)attr[0]); } return(null); }
public TextureAtlas ReadTextureJsonFile (AndroidGameActivity activity, string jsonFile, Texture2D texture) #endif { var regions = new Dictionary<string, TextureRegion>(); string jsonText = null; #if WINDOWS jsonText = File.ReadAllText(jsonFile); #elif ANDROID using (var inputStram = activity.Assets.Open(jsonFile)) { jsonText = new StreamReader(inputStram).ReadToEnd(); } #endif JObject data = JObject.Parse(jsonText); foreach (JToken frame in data["frames"]) { Rectangle textureAtlasArea; string filename = Path.GetFileNameWithoutExtension((string) frame["filename"]); bool rotated = Read(frame, "rotated", false); JToken details = frame["frame"]; int x = Read(details, "x", 0); int y = Read(details, "y", 0); int width = Read(details, "w", 0); int height = Read(details, "h", 0); if (rotated) { // The image inside our texture map is rotated so swap width and height textureAtlasArea = new Rectangle(x, y, height, width); } else { textureAtlasArea = new Rectangle(x, y, width, height); } regions.Add(filename, new TextureRegion(texture, rotated, textureAtlasArea)); } return new TextureAtlas(texture, regions); }
public AndroidGameWindow(AndroidGameActivity activity, Game game) { _game = game; Point size; if (Build.VERSION.SdkInt < BuildVersionCodes.JellyBean) { size.X = activity.Resources.DisplayMetrics.WidthPixels; size.Y = activity.Resources.DisplayMetrics.HeightPixels; } else { Android.Graphics.Point p = new Android.Graphics.Point(); activity.WindowManager.DefaultDisplay.GetRealSize(p); size.X = p.X; size.Y = p.Y; } Initialize(activity, size); game.Services.AddService(typeof(View), GameView); }
/// <summary> /// Constructor. SensorDelay.Ui is passed to the base class as this orientation listener /// is just used for flipping the screen orientation, therefore high frequency data is not required. /// </summary> public OrientationListener(AndroidGameActivity activity) : base(activity, SensorDelay.Ui) { this.activity = activity; }
public OrientationListener(AndroidGameActivity activity) : base(activity, 1) { this.activity = activity; }
public OrientationListener(AndroidGameActivity activity) : base(activity, Android.Hardware.SensorDelay.Game) { this.activity = activity; }
public Game(AndroidGameActivity context) { contextInstance = context; context.Game = this; // Initialize collections _services = new GameServiceContainer(); _gameComponentCollection = new GameComponentCollection(); view = new AndroidGameWindow(context); view.game = this; // Initialize GameTime _updateGameTime = new GameTime(); _drawGameTime = new GameTime(); }
/// <summary> /// Constructor. SensorDelay.Ui is passed to the base class as this orientation listener /// is just used for flipping the screen orientation, therefore high frequency data is not required. /// </summary> public OrientationListener(AndroidGameActivity activity) : base(activity, SensorDelay.Ui) { this.activity = activity; this.defaultOrientation = GetDeviceDefaultOrientation(); }