protected override void DrawScreen(SpriteBatch spriteBatch, DisplayOrientation screenOrientation) { background.Draw(spriteBatch); road.Draw(spriteBatch); car.Draw(spriteBatch); hazards.Draw(spriteBatch); }
private Orientation GetOrientation(DisplayOrientation xnaOrientation) { Orientation = xnaOrientation == DisplayOrientation.LandscapeLeft || xnaOrientation == DisplayOrientation.LandscapeRight ? Orientation.Landscape : Orientation.Portrait; return Orientation; }
protected override void DrawScreen(SpriteBatch batch, DisplayOrientation screenOrientation) { Globals.map.Draw(batch); Globals.Mobs.Draw(batch); player.Draw(batch); HUDPlayerInfo.Draw(batch); }
protected override void UpdateScreen(GameTime gameTime, DisplayOrientation displayOrientation) { if (input.CheckMousePress(ScreenRectangle)) { changeScreenDelegate(ScreenState.Title); } }
protected override void UpdateScreen(GameTime gameTime, DisplayOrientation displayOrientation) { if (input.CheckMousePress(gameButton)) { changeScreenDelegate(ScreenState.Gameplay); } }
public GraphicsDeviceManager(Game game) { if (game == null) { throw new ArgumentNullException("The game cannot be null!"); } this.game = game; supportedOrientations = DisplayOrientation.Default; PreferredBackBufferHeight = DefaultBackBufferHeight; PreferredBackBufferWidth = DefaultBackBufferWidth; PreferredBackBufferFormat = SurfaceFormat.Color; PreferredDepthStencilFormat = DepthFormat.Depth24; SynchronizeWithVerticalRetrace = true; if (game.Services.GetService(typeof(IGraphicsDeviceManager)) != null) { throw new ArgumentException("Graphics Device Manager Already Present"); } game.Services.AddService(typeof(IGraphicsDeviceManager), this); game.Services.AddService(typeof(IGraphicsDeviceService), this); }
protected override void DrawScreen(SpriteBatch batch, DisplayOrientation displayOrientation) { background.Draw(batch); batch.Draw(optionsText, new Rectangle(0, 0, ScreenWidth, ScreenHeight), Color.White); fullscreenButton.Draw(batch); backButton.Draw(batch); }
protected override void DrawScreen(SpriteBatch spriteBatch, DisplayOrientation screenOrientation) { background.Draw(spriteBatch); titleText.Draw(spriteBatch); startButton.Draw(spriteBatch); exitButton.Draw(spriteBatch); }
public ScreenConfig() { // set defaults. this.Width = 0; // make default resolution 0x0, so that it'll be only set if a platform requires so and sets the values - otherwise the system default will be used. this.Height = 0; this.IsFullScreen = false; this.SupportedOrientations = DisplayOrientation.Default; }
protected override void DrawScreen(SpriteBatch batch, DisplayOrientation displayOrientation) { background.Draw(batch); batch.Draw(titleText, new Rectangle(0, 0, ScreenWidth, ScreenHeight), Color.White); gameButton.Draw(batch); optionsButton.Draw(batch); exitButton.Draw(batch); }
protected override void UpdateScreen(GameTime gameTime, DisplayOrientation screenOrientation) { road.Update(gameTime); car.Update(gameTime); hazards.Update(gameTime, car, HandleCarCollision); if (previousHazardCount != hazards.HazardCount) { soundEffects.PlaySound("SoundEffects/HazardPass"); previousHazardCount = hazards.HazardCount; } }
protected override void UpdateScreen(GameTime gameTime, DisplayOrientation displayOrientation) { if(input.CheckMousePress(fullscreenButton)) { graphics.ToggleFullScreen(); } if(input.CheckMousePress(backButton)) { changeScreenDelegate(ScreenState.Title); } }
public static AccelerometerReading GetReading(DisplayOrientation orientation) { if (orientation == DisplayOrientation.Portrait) { return new AccelerometerReading(state,timeStamp); } var landLeft = new Vector3(-state.Y, state.X, state.Z); if (orientation == DisplayOrientation.LandscapeLeft || orientation == DisplayOrientation.Default) { return new AccelerometerReading(landLeft, timeStamp); } return new AccelerometerReading(landLeft,timeStamp ); }
public Monitor(double left, double top, double width, double height, DisplayOrientation orientation) : base("Monitor", new Size(width, height)) { Top = top; Left = left; Width = width; Height = height; _orientation = orientation; if (Top == 0 && Left == 0) { _fillBackground = false; } }
protected override void UpdateScreen(GameTime gameTime, DisplayOrientation screenOrientation) { if (input.IsPressed(ActionStart)) { soundEffects.PlaySound("SoundEffects/Select"); changeScreenDelegate(ScreenState.MainGame); } else if (input.IsPressed(ActionExit)) { soundEffects.PlaySound("SoundEffects/Select"); changeScreenDelegate(ScreenState.Exit); } }
public void UpdateWP7InputState(GameTime gameTime, DisplayOrientation currentOrientation) { // DAK - Disabled this code because it was consuming Gestures before our app could process them. //mCurrentOrientation = currentOrientation; //#region Gesture support //mHasTap = false; //mHasTapTwo = false; //mHDelta = 0.0f; //mVDelta = 0.0f; //if (TouchPanel.IsGestureAvailable) { // GestureSample g = TouchPanel.ReadGesture(); // switch (g.GestureType) // { // case GestureType.Tap: // mHasTap = true; // break; // case GestureType.Pinch: // if (!mPinchHasBegin) // { // mHasTapTwo = true; // mPinchHasBegin = true; // } // break; // case GestureType.PinchComplete: // mPinchHasBegin = false; // break; // case GestureType.FreeDrag: // float x= (g.Delta.X) * kDRAG_UNIT; // x = MathHelper.Clamp(x, -1f, 1f); // float y= -(g.Delta.Y) * kDRAG_UNIT; // y = MathHelper.Clamp(y, -1f, 1f); // mHDelta = x; // mVDelta = y; // break; // } //} //#endregion }
public void Draw(GameTime gameTime, SpriteBatch spriteBatch, DisplayOrientation orientation) { switch (orientation) { case DisplayOrientation.LandscapeLeft: Draw_Content(spriteBatch, _landscape); break; case DisplayOrientation.LandscapeRight: Draw_Content(spriteBatch, _landscape); break; case DisplayOrientation.Portrait: Draw_Content(spriteBatch, _portrait); break; case DisplayOrientation.Default: Draw_Content(spriteBatch, _portrait); break; } }
public GraphicsDeviceManager(Game game) { if (game == null) { throw new ArgumentNullException ("Game Cannot Be Null"); } _game = game; _supportedOrientations = DisplayOrientation.Default; if (game.Services.GetService (typeof(IGraphicsDeviceManager)) != null) { throw new ArgumentException ("Graphics Device Manager Already Present"); } game.Services.AddService (typeof(IGraphicsDeviceManager), this); game.Services.AddService (typeof(IGraphicsDeviceService), this); CreateDevice(); }
public void ApplyChanges() { ThrowIfNotService(); // Store software settings appliedSupportedOrientations = SupportedOrientations; if(appliedSupportedOrientations == DisplayOrientation.Default) { if(PreferredBackBufferHeight > PreferredBackBufferWidth) appliedSupportedOrientations = DisplayOrientation.Portrait; else appliedSupportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight; } // Set Android requested orientations bool portrait = (appliedSupportedOrientations & DisplayOrientation.Portrait) != 0; bool landscapeLeft = (appliedSupportedOrientations & DisplayOrientation.LandscapeLeft) != 0; bool landscapeRight = (appliedSupportedOrientations & DisplayOrientation.LandscapeRight) != 0; // BUG: Android makes it difficult to support both landscape orientations... // so for the time being, ExEn for Android doesn't either. if(landscapeLeft != landscapeRight) ExEnLog.WriteLine("WARNING: ExEn for Android cannot handle mismatched landscape modes"); bool landscape = landscapeLeft || landscapeRight; if(portrait == landscape) // both (or neither, which shouldn't happen) { //activity.SetRequestedOrientation(Android.Content.PM.ScreenOrientation.Sensor); } else if(landscape) { // NOTE: Would prefer to use sensorLandscape, but that is only introduced in API level 9 // TODO: If adding support for different API versions, add a conditional that uses // sensorLandscape on API level 9+ //activity.SetRequestedOrientation(Android.Content.PM.ScreenOrientation.Landscape); } else // portrait { // As above, would prefer to use sensorPortrait, but this requires API level 9 // I'm fairly sure that a phone-style device will treat sensorPortrait as portrait // (no upside-down-portrait), and a pad will support it fully. This matches the // difference between iPhone and iPad. //activity.SetRequestedOrientation(Android.Content.PM.ScreenOrientation.Portrait); } }
public void ApplyChanges() { ThrowIfNotService(); // Store software settings appliedSupportedOrientations = SupportedOrientations; if(appliedSupportedOrientations == DisplayOrientation.Default) { if(PreferredBackBufferHeight > PreferredBackBufferWidth) appliedSupportedOrientations = DisplayOrientation.Portrait; else appliedSupportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight; } Console.WriteLine("Setting supported orientations = " + appliedSupportedOrientations); // Not supporting this for the time being... // UIApplication.SharedApplication.StatusBarHidden = IsFullScreen; }
public GraphicsDeviceManager(Game game) { if (game == null) { throw new ArgumentNullException ("Game Cannot Be Null"); } _game = game; _supportedOrientations = DisplayOrientation.Default; _preferredBackBufferHeight = PresentationParameters._defaultBackBufferHeight; _preferredBackBufferWidth = PresentationParameters._defaultBackBufferWidth; if (game.Services.GetService (typeof(IGraphicsDeviceManager)) != null) { throw new ArgumentException ("Graphics Device Manager Already Present"); } game.Services.AddService (typeof(IGraphicsDeviceManager), this); game.Services.AddService (typeof(IGraphicsDeviceService), this); }
public GraphicsDeviceManager(Game game) { if (game == null) { throw new ArgumentNullException("Game Cannot Be Null"); } _game = game; _preferredBackBufferHeight = game.Window.ClientBounds.Height; _preferredBackBufferWidth = game.Window.ClientBounds.Width; _supportedOrientations = DisplayOrientation.Default; if (game.Services.GetService(typeof(IGraphicsDeviceManager)) != null) { throw new ArgumentException("Graphics Device Manager Already Present"); } game.Services.AddService(typeof(IGraphicsDeviceManager), this); game.Services.AddService(typeof(IGraphicsDeviceService), this); Initialize(); // Read the ActivityAttribute and check if the ScreenOrientation is set // and set the window Orientation to match /* var attribute = Game.Activity.GetActivityAttribute(); if (attribute != null) { switch (attribute.ScreenOrientation) { case Android.Content.PM.ScreenOrientation.Portrait: _game.Window.SetOrientation(DisplayOrientation.Portrait); break; case Android.Content.PM.ScreenOrientation.Landscape: default : _game.Window.SetOrientation(DisplayOrientation.LandscapeLeft); break; } }*/ }
public override async Task<DisplayOrientation> GetOrientationCurrent() { var currentOrientation = SimpleOrientationSensor.GetDefault().GetCurrentOrientation(); switch (currentOrientation) { case SimpleOrientation.Faceup: case SimpleOrientation.Facedown: break; case SimpleOrientation.NotRotated: case SimpleOrientation.Rotated180DegreesCounterclockwise: CurrentDisplayOrientation = DisplayOrientation.Portrait; break; case SimpleOrientation.Rotated270DegreesCounterclockwise: case SimpleOrientation.Rotated90DegreesCounterclockwise: CurrentDisplayOrientation = DisplayOrientation.Landscape; break; default: CurrentDisplayOrientation = DisplayOrientation.Unknown; break; } return CurrentDisplayOrientation; }
public GraphicsDeviceManager(Game game) { if (game == null) { throw new ArgumentNullException("Game Cannot Be Null"); } Game.contextInstance.RequestWindowFeature(WindowFeatures.NoTitle); _game = game; _preferredBackBufferHeight = game.Window.ClientBounds.Height; _preferredBackBufferWidth = game.Window.ClientBounds.Width; _supportedOrientations = DisplayOrientation.Default; if (game.Services.GetService(typeof(IGraphicsDeviceManager)) != null) { throw new ArgumentException("Graphics Device Manager Already Present"); } game.Services.AddService(typeof(IGraphicsDeviceManager), this); game.Services.AddService(typeof(IGraphicsDeviceService), this); Initialize(); }
protected internal override void SetSupportedOrientations(DisplayOrientation orientations) { // We don't want to trigger orientation changes // when no preference is being changed. if (_supportedOrientations == orientations) return; _supportedOrientations = orientations; DisplayOrientations supported; if (orientations == DisplayOrientation.Default) { // Make the decision based on the preferred backbuffer dimensions. var manager = Game.graphicsDeviceManager; if (manager.PreferredBackBufferWidth > manager.PreferredBackBufferHeight) supported = FromOrientation(DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight); else supported = FromOrientation(DisplayOrientation.Portrait | DisplayOrientation.PortraitDown); } else supported = FromOrientation(orientations); DisplayInformation.AutoRotationPreferences = supported; }
public void InteractMotion(MotionReading motion, DisplayOrientation orientation) { }
/// <inheritdoc /> protected internal override void SetSupportedOrientations(DisplayOrientation orientations) { // orientations are not supported on Desktop platform }
internal protected override void SetSupportedOrientations(DisplayOrientation orientations) { _viewController.SupportedOrientations = orientations; }
protected override void UpgradeAsset(AssetMigrationContext context, PackageVersion currentVersion, PackageVersion targetVersion, dynamic asset, PackageLoadingAssetFile assetFile, OverrideUpgraderHint overrideHint) { int backBufferWidth = asset.BackBufferWidth ?? 1280; asset.RemoveChild("BackBufferWidth"); int backBufferHeight = asset.BackBufferHeight ?? 720; asset.RemoveChild("BackBufferHeight"); GraphicsProfile profile = asset.DefaultGraphicsProfile ?? GraphicsProfile.Level_9_1; asset.RemoveChild("DefaultGraphicsProfile"); ColorSpace colorSpace = asset.ColorSpace ?? ColorSpace.Linear; asset.RemoveChild("ColorSpace"); DisplayOrientation displayOrientation = asset.DisplayOrientation ?? DisplayOrientation.Default; asset.RemoveChild("DisplayOrientation"); TextureQuality textureQuality = asset.TextureQuality ?? TextureQuality.Fast; asset.RemoveChild("TextureQuality"); var renderingMode = RenderingMode.HDR; if (asset.RenderingMode != null) { if (asset.RenderingMode == "LDR") { renderingMode = RenderingMode.LDR; } } asset.RemoveChild("RenderingMode"); var configurations = new DynamicYamlArray(new YamlSequenceNode()); asset.Defaults = configurations; dynamic renderingSettings = new DynamicYamlMapping(new YamlMappingNode { Tag = "!SiliconStudio.Xenko.Graphics.RenderingSettings,SiliconStudio.Xenko.Graphics" }); renderingSettings.DefaultBackBufferWidth = backBufferWidth; renderingSettings.DefaultBackBufferHeight = backBufferHeight; renderingSettings.DefaultGraphicsProfile = profile; renderingSettings.ColorSpace = colorSpace; renderingSettings.DisplayOrientation = displayOrientation; asset.Defaults.Add(renderingSettings); dynamic editorSettings = new DynamicYamlMapping(new YamlMappingNode { Tag = "!SiliconStudio.Xenko.Assets.EditorSettings,SiliconStudio.Xenko.Assets" }); editorSettings.RenderingMode = renderingMode; asset.Defaults.Add(editorSettings); dynamic textSettings = new DynamicYamlMapping(new YamlMappingNode { Tag = "!SiliconStudio.Xenko.Assets.Textures.TextureSettings,SiliconStudio.Xenko.Assets" }); textSettings.TextureQuality = textureQuality; asset.Defaults.Add(textSettings); dynamic physicsSettings = new DynamicYamlMapping(new YamlMappingNode { Tag = "!SiliconStudio.Xenko.Physics.PhysicsSettings,SiliconStudio.Xenko.Physics" }); asset.Defaults.Add(physicsSettings); var defaultFilters = new DynamicYamlArray(new YamlSequenceNode()); asset.PlatformFilters = defaultFilters; asset.PlatformFilters.Add("PowerVR SGX 54[0-9]"); asset.PlatformFilters.Add("Adreno \\(TM\\) 2[0-9][0-9]"); asset.PlatformFilters.Add("Adreno (TM) 320"); asset.PlatformFilters.Add("Adreno (TM) 330"); asset.PlatformFilters.Add("Adreno \\(TM\\) 4[0-9][0-9]"); asset.PlatformFilters.Add("NVIDIA Tegra"); asset.PlatformFilters.Add("Intel(R) HD Graphics"); asset.PlatformFilters.Add("^Mali\\-4"); asset.PlatformFilters.Add("^Mali\\-T6"); asset.PlatformFilters.Add("^Mali\\-T7"); }
protected override void OnOrientationChanged(DisplayOrientation orientation) { base.OnOrientationChanged(orientation); ChangeLayout(); }
public static void SetOrientation(PackageTemplateGeneratorParameters parameters, DisplayOrientation displayOrientation) => parameters.SetTag(OrientationKey, displayOrientation);
protected virtual void DrawScreen(SpriteBatch batch, DisplayOrientation screenOrientation) { // batch.Draw(blackScreen, fadeScreen, fadeColor); //used for fading to black }
protected internal override void SetSupportedOrientations(DisplayOrientation orientations) { // Do nothing. Desktop platforms don't do orientation. }
public static ProjectReference GenerateTemplate(TemplateGeneratorParameters parameters, ICollection <SelectedSolutionPlatform> platforms, Package package, UFile templateRelativePath, string projectName, PlatformType platformType, string currentProfile, GraphicsPlatform?graphicsPlatform, ProjectType projectType, DisplayOrientation orientation, Guid?projectGuid = null) { AddOption(parameters, "Platforms", platforms.Select(x => x.Platform).ToList()); AddOption(parameters, "CurrentPlatform", platformType); AddOption(parameters, "CurrentProfile", currentProfile); AddOption(parameters, "Orientation", orientation); List <string> generatedFiles; var projectReference = GenerateTemplate(parameters, package, templateRelativePath, projectName, platformType, graphicsPlatform, projectType, out generatedFiles, projectGuid); // Special case for xkfx files foreach (var file in generatedFiles) { if (file.EndsWith(".xkfx")) { ConvertXkfxToCSharp(file); } } return(projectReference); }
protected virtual void UpdateScreen(GameTime gameTime, DisplayOrientation screenOrientation) { }
private void SetDisplayOrientation(DisplayOrientation value) { if (value != _currentOrientation) { DisplayOrientation supported = GetEffectiveSupportedOrientations(); ScreenOrientation requestedOrientation = ScreenOrientation.Unspecified; bool wasPortrait = _currentOrientation == DisplayOrientation.Portrait || _currentOrientation == DisplayOrientation.PortraitDown; bool requestPortrait = false; bool didOrientationChange = false; // Android 2.3 and above support reverse orientations int sdkVer = (int)Android.OS.Build.VERSION.SdkInt; if (sdkVer >= 10) { // Check if the requested orientation is supported. Default means all are supported. if ((supported & value) != 0) { didOrientationChange = true; _currentOrientation = value; switch (value) { case DisplayOrientation.LandscapeLeft: requestedOrientation = (ScreenOrientation)ScreenOrientationAll.Landscape; requestPortrait = false; break; case DisplayOrientation.LandscapeRight: requestedOrientation = (ScreenOrientation)ScreenOrientationAll.ReverseLandscape; requestPortrait = false; break; case DisplayOrientation.Portrait: requestedOrientation = (ScreenOrientation)ScreenOrientationAll.Portrait; requestPortrait = true; break; case DisplayOrientation.PortraitDown: requestedOrientation = (ScreenOrientation)ScreenOrientationAll.ReversePortrait; requestPortrait = true; break; } } } else { // Check if the requested orientation is either of the landscape orientations and any landscape orientation is supported. if ((value == DisplayOrientation.LandscapeLeft || value == DisplayOrientation.LandscapeRight) && ((supported & (DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight)) != 0)) { didOrientationChange = true; _currentOrientation = DisplayOrientation.LandscapeLeft; requestedOrientation = ScreenOrientation.Landscape; requestPortrait = false; } // Check if the requested orientation is either of the portrain orientations and any portrait orientation is supported. else if ((value == DisplayOrientation.Portrait || value == DisplayOrientation.PortraitDown) && ((supported & (DisplayOrientation.Portrait | DisplayOrientation.PortraitDown)) != 0)) { didOrientationChange = true; _currentOrientation = DisplayOrientation.Portrait; requestedOrientation = ScreenOrientation.Portrait; requestPortrait = true; } } if (didOrientationChange) { // Android doesn't fire Released events for existing touches // so we need to clear them out. if (wasPortrait != requestPortrait) { TouchPanelState.ReleaseAllTouches(); } Game.Activity.RequestedOrientation = requestedOrientation; OnOrientationChanged(); } } }
private void ChangeOrCreateDevice(bool forceCreate) { if (forceCreate) { // Make sure that all GraphicsAdapter are cleared and removed when device is disposed. GraphicsAdapter.Dispose(); // Make sure that GraphicsAdapter are initialized. GraphicsAdapter.Initialize(); } isChangingDevice = true; int width = game.Window.ClientBounds.Width; int height = game.Window.ClientBounds.Height; bool isBeginScreenDeviceChange = false; try { // Notifies the game window for the new orientation game.Window.SetSupportedOrientations(SelectOrientation(supportedOrientations, PreferredBackBufferWidth, PreferredBackBufferHeight, true)); var graphicsDeviceInformation = FindBestDevice(forceCreate); game.Window.BeginScreenDeviceChange(graphicsDeviceInformation.PresentationParameters.IsFullScreen); isBeginScreenDeviceChange = true; bool needToCreateNewDevice = true; // If we are not forced to create a new device and this is already an existing GraphicsDevice // try to reset and resize it. if (!forceCreate && GraphicsDevice != null) { OnPreparingDeviceSettings(this, new PreparingDeviceSettingsEventArgs(graphicsDeviceInformation)); if (CanResetDevice(graphicsDeviceInformation)) { try { var newWidth = graphicsDeviceInformation.PresentationParameters.BackBufferWidth; var newHeight = graphicsDeviceInformation.PresentationParameters.BackBufferHeight; var newFormat = graphicsDeviceInformation.PresentationParameters.BackBufferFormat; var newOutputIndex = graphicsDeviceInformation.PresentationParameters.PreferredFullScreenOutputIndex; GraphicsDevice.Presenter.PrefferedFullScreenOutputIndex = newOutputIndex; GraphicsDevice.Presenter.Resize(newWidth, newHeight, newFormat); // Change full screen if needed GraphicsDevice.Presenter.IsFullScreen = graphicsDeviceInformation.PresentationParameters.IsFullScreen; needToCreateNewDevice = false; } catch { } } } // If we still need to create a device, then we need to create it if (needToCreateNewDevice) { CreateDevice(graphicsDeviceInformation); } var presentationParameters = GraphicsDevice.Presenter.Description; isReallyFullScreen = presentationParameters.IsFullScreen; if (presentationParameters.BackBufferWidth != 0) { width = presentationParameters.BackBufferWidth; } if (presentationParameters.BackBufferHeight != 0) { height = presentationParameters.BackBufferHeight; } deviceSettingsChanged = false; } finally { if (isBeginScreenDeviceChange) { game.Window.EndScreenDeviceChange(width, height); } currentWindowOrientation = game.Window.CurrentOrientation; isChangingDevice = false; } }
public static void UpdatePackagePlatforms(TemplateGeneratorParameters parameters, ICollection <SelectedSolutionPlatform> platforms, DisplayOrientation orientation, Guid sharedProjectGuid, string name, Package package, bool forcePlatformRegeneration) { if (platforms == null) { throw new ArgumentNullException(nameof(platforms)); } var logger = parameters.Logger; // Setup the ProjectGameGuid to be accessible from exec (in order to be able to link to the game project. AddOption(parameters, "ProjectGameGuid", sharedProjectGuid); // Add projects var stepIndex = 0; var stepCount = platforms.Count + 1; var profilesToRemove = package.Profiles.Where(profile => platforms.All(platform => profile.Platform != PlatformType.Shared && platform.Platform.Type != profile.Platform)).ToList(); stepCount += profilesToRemove.Count; foreach (var platform in platforms) { stepIndex++; // Don't add a platform that is already in the package var platformProfile = package.Profiles.FirstOrDefault(profile => profile.Platform == platform.Platform.Type); if (platformProfile != null && !forcePlatformRegeneration) { continue; } var projectGuid = Guid.NewGuid(); if (platformProfile == null) { platformProfile = new PackageProfile(platform.Platform.Name) { Platform = platform.Platform.Type }; platformProfile.AssetFolders.Add(new AssetFolder("Assets/" + platform.Platform.Name)); } else { // We are going to regenerate this platform, so we are removing it before var previousExeProject = platformProfile.ProjectReferences.FirstOrDefault(project => project.Type == ProjectType.Executable); if (previousExeProject != null) { projectGuid = previousExeProject.Id; RemoveProject(previousExeProject, logger); platformProfile.ProjectReferences.Remove(previousExeProject); } } var templatePath = platform.Template?.TemplatePath ?? $"ProjectExecutable.{platform.Platform.Name}/ProjectExecutable.{platform.Platform.Name}.ttproj"; // Log progress var projectName = Utilities.BuildValidNamespaceName(name) + "." + platform.Platform.Name; Progress(logger, $"Generating {projectName}...", stepIndex - 1, stepCount); var graphicsPlatform = platform.Platform.Type.GetDefaultGraphicsPlatform(); var newExeProject = GenerateTemplate(parameters, platforms, package, templatePath, projectName, platform.Platform.Type, platformProfile.Name, graphicsPlatform, ProjectType.Executable, orientation, projectGuid); newExeProject.Type = ProjectType.Executable; platformProfile.ProjectReferences.Add(newExeProject); if (!package.Profiles.Contains(platformProfile)) { package.Profiles.Add(platformProfile); } package.IsDirty = true; } // Remove existing platform profiles foreach (var profileToRemove in profilesToRemove) { package.Profiles.Remove(profileToRemove); package.IsDirty = true; foreach (var projectReference in profileToRemove.ProjectReferences) { // Try to remove the directory Progress(logger, $"Deleting {projectReference.Location}...", stepIndex++, stepCount); RemoveProject(projectReference, logger); } // We are completely removing references from profile profileToRemove.ProjectReferences.Clear(); } }
protected internal override void SetSupportedOrientations(DisplayOrientation orientations) { // Nothing to do here }
protected internal override void SetSupportedOrientations(DisplayOrientation orientations) { // No-op. SDL2 has no orientation. }
protected internal abstract void SetSupportedOrientations(DisplayOrientation orientations);
private void ObserveDeviceRotation() { if (game.graphicsDeviceManager == null) { return; } // Calculate supported orientations if it has been left as "default" DisplayOrientation supportedOrientations = (game.graphicsDeviceManager as GraphicsDeviceManager).SupportedOrientations; if ((supportedOrientations & DisplayOrientation.Default) != 0) { if (game.GraphicsDevice.PresentationParameters.BackBufferWidth > game.GraphicsDevice.PresentationParameters.BackBufferHeight) { supportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight; } else { supportedOrientations = DisplayOrientation.Portrait | DisplayOrientation.PortraitUpsideDown; } } switch (Resources.Configuration.Orientation) { case Orientation.Portrait: if ((supportedOrientations & DisplayOrientation.Portrait) != 0) { CurrentOrientation = DisplayOrientation.Portrait; game.GraphicsDevice.PresentationParameters.DisplayOrientation = DisplayOrientation.Portrait; TouchPanel.DisplayOrientation = DisplayOrientation.Portrait; } break; case Orientation.Landscape: // TODO: Since the system cannot tell us if it is left or right, we may need to use one of the other sensors // to determine actual orientation. At this stage it chooses left (if set) over right (if set). DisplayOrientation orientation = DisplayOrientation.Unknown; if ((supportedOrientations & DisplayOrientation.LandscapeLeft) != 0) { orientation = DisplayOrientation.LandscapeLeft; } else if ((supportedOrientations & DisplayOrientation.LandscapeRight) != 0) { orientation = DisplayOrientation.LandscapeRight; } if (orientation != DisplayOrientation.Unknown) { CurrentOrientation = orientation; game.GraphicsDevice.PresentationParameters.DisplayOrientation = orientation; TouchPanel.DisplayOrientation = orientation; } break; case Orientation.Undefined: if ((supportedOrientations & DisplayOrientation.Unknown) != 0) { CurrentOrientation = DisplayOrientation.Unknown; TouchPanel.DisplayOrientation = DisplayOrientation.Unknown; } break; default: break; } }
protected internal override void SetSupportedOrientations(DisplayOrientation orientations) { // Desktop doesn't have orientation (unless on Windows 8?) }
internal void SetOrientation(DisplayOrientation currentorientation) { var deviceManager = (GraphicsDeviceManager)_game.Services.GetService(typeof(IGraphicsDeviceManager)); if (deviceManager == null) { return; } // Calculate supported orientations if it has been left as "default" and only default DisplayOrientation supportedOrientations = (deviceManager as GraphicsDeviceManager).SupportedOrientations; var allowedOrientation = DisplayOrientation.LandscapeLeft; if ((supportedOrientations == DisplayOrientation.Default)) { // if we have default only we only allow Landscape allowedOrientation = allowedOrientation | DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight; } if ((supportedOrientations == DisplayOrientation.LandscapeLeft)) { // if we have default only we only allow Landscape allowedOrientation = DisplayOrientation.LandscapeLeft; } if ((supportedOrientations & DisplayOrientation.LandscapeLeft) != 0) { // if we have default only we only allow Landscape allowedOrientation = allowedOrientation | DisplayOrientation.LandscapeLeft; } if ((supportedOrientations == DisplayOrientation.LandscapeRight)) { // if we have default only we only allow Landscape allowedOrientation = DisplayOrientation.LandscapeRight; } if ((supportedOrientations & DisplayOrientation.LandscapeRight) != 0) { // if we have default only we only allow Landscape allowedOrientation = allowedOrientation | DisplayOrientation.LandscapeRight; } if ((supportedOrientations == DisplayOrientation.Portrait)) { // if we have Portrait only we only allow Landscape allowedOrientation = DisplayOrientation.Portrait; } if ((supportedOrientations & DisplayOrientation.Portrait) != 0) { // if we have default only we only allow Landscape allowedOrientation = allowedOrientation | DisplayOrientation.Portrait; } //What is this for? This does not allow the application to use landscapeleft. //if (deviceManager.PreferredBackBufferSetByUser) //{ // if (_game.GraphicsDevice.PresentationParameters.BackBufferHeight < _game.GraphicsDevice.PresentationParameters.BackBufferWidth) // { // allowedOrientation = DisplayOrientation.LandscapeLeft; // } // if (_game.GraphicsDevice.PresentationParameters.BackBufferHeight > _game.GraphicsDevice.PresentationParameters.BackBufferWidth) // { // allowedOrientation = DisplayOrientation.Portrait; // } //} // ok we default to landscape left var actualOrientation = DisplayOrientation.LandscapeLeft; // now based on the orientation of the device we // decide of we honour the device orientation or force our own // so if we are in Portrait but we allow only LandScape we stay in landscape if (allowedOrientation == DisplayOrientation.Portrait) { actualOrientation = DisplayOrientation.Portrait; } else if (allowedOrientation == DisplayOrientation.LandscapeLeft) { actualOrientation = DisplayOrientation.LandscapeLeft; } else if (allowedOrientation == DisplayOrientation.LandscapeRight) { actualOrientation = DisplayOrientation.LandscapeRight; } else if (_game.GraphicsDevice != null && _game.GraphicsDevice.PresentationParameters.BackBufferHeight < _game.GraphicsDevice.PresentationParameters.BackBufferWidth && deviceManager.PreferredBackBufferSetByUser) { actualOrientation = DisplayOrientation.LandscapeLeft; } else if (_game.GraphicsDevice != null && _game.GraphicsDevice.PresentationParameters.BackBufferHeight > _game.GraphicsDevice.PresentationParameters.BackBufferWidth && deviceManager.PreferredBackBufferSetByUser) { actualOrientation = DisplayOrientation.Portrait; } switch (currentorientation) { case DisplayOrientation.Portrait: if ((allowedOrientation & DisplayOrientation.Portrait) != 0) { actualOrientation = DisplayOrientation.Portrait; } break; case DisplayOrientation.LandscapeRight: if ((allowedOrientation & DisplayOrientation.LandscapeRight) != 0) { actualOrientation = DisplayOrientation.LandscapeRight; } break; case DisplayOrientation.LandscapeLeft: default: if ((allowedOrientation & DisplayOrientation.LandscapeLeft) != 0) { actualOrientation = DisplayOrientation.LandscapeLeft; } break; } CurrentOrientation = actualOrientation; _game.GraphicsDevice.PresentationParameters.DisplayOrientation = actualOrientation; TouchPanel.DisplayOrientation = actualOrientation; }
private void ChangeOrCreateDevice(bool forceCreate) { // We make sure that we won't be call by an asynchronous event (windows resized) lock (lockDeviceCreation) using (var profile = Profiler.Begin(GraphicsDeviceManagerProfilingKeys.CreateDevice)) { isChangingDevice = true; int width = game.Window.ClientBounds.Width; int height = game.Window.ClientBounds.Height; bool isBeginScreenDeviceChange = false; try { // Notifies the game window for the new orientation var orientation = SelectOrientation(supportedOrientations, PreferredBackBufferWidth, PreferredBackBufferHeight, true); game.Window.SetSupportedOrientations(orientation); var graphicsDeviceInformation = FindBestDevice(forceCreate); OnPreparingDeviceSettings(this, new PreparingDeviceSettingsEventArgs(graphicsDeviceInformation)); isFullScreen = graphicsDeviceInformation.PresentationParameters.IsFullScreen; game.Window.BeginScreenDeviceChange(graphicsDeviceInformation.PresentationParameters.IsFullScreen); isBeginScreenDeviceChange = true; bool needToCreateNewDevice = true; // If we are not forced to create a new device and this is already an existing GraphicsDevice // try to reset and resize it. if (!forceCreate && GraphicsDevice != null) { if (CanResetDevice(graphicsDeviceInformation)) { try { var newWidth = graphicsDeviceInformation.PresentationParameters.BackBufferWidth; var newHeight = graphicsDeviceInformation.PresentationParameters.BackBufferHeight; var newFormat = graphicsDeviceInformation.PresentationParameters.BackBufferFormat; var newOutputIndex = graphicsDeviceInformation.PresentationParameters.PreferredFullScreenOutputIndex; GraphicsDevice.Presenter.Description.PreferredFullScreenOutputIndex = newOutputIndex; GraphicsDevice.Presenter.Description.RefreshRate = graphicsDeviceInformation.PresentationParameters.RefreshRate; GraphicsDevice.Presenter.Resize(newWidth, newHeight, newFormat); // Change full screen if needed GraphicsDevice.Presenter.IsFullScreen = graphicsDeviceInformation.PresentationParameters.IsFullScreen; needToCreateNewDevice = false; } catch { } } } // If we still need to create a device, then we need to create it if (needToCreateNewDevice) { CreateDevice(graphicsDeviceInformation); } if (GraphicsDevice == null) { throw new InvalidOperationException("Unexpected null GraphicsDevice"); } // Make sure to copy back coolor space to GraphicsDevice GraphicsDevice.ColorSpace = graphicsDeviceInformation.PresentationParameters.ColorSpace; var presentationParameters = GraphicsDevice.Presenter.Description; isReallyFullScreen = presentationParameters.IsFullScreen; if (presentationParameters.BackBufferWidth != 0) { width = presentationParameters.BackBufferWidth; } if (presentationParameters.BackBufferHeight != 0) { height = presentationParameters.BackBufferHeight; } deviceSettingsChanged = false; } finally { if (isBeginScreenDeviceChange) { game.Window.EndScreenDeviceChange(width, height); } currentWindowOrientation = game.Window.CurrentOrientation; isChangingDevice = false; } } }
internal OrientationChangedEventArgs(Native.SDL_DisplayEvent display) : base(display.Timestamp) { Orientation = (DisplayOrientation)display.Data; }
private void ObserveDeviceRotation() { NSNotificationCenter.DefaultCenter.AddObserver(new NSString("UIDeviceOrientationDidChangeNotification"), (notification) => { UIDeviceOrientation orientation = UIDevice.CurrentDevice.Orientation; // Calculate supported orientations if it has been left as "default" DisplayOrientation supportedOrientations = (graphicsDeviceManager as GraphicsDeviceManager).SupportedOrientations; if ((supportedOrientations & DisplayOrientation.Default) != 0) { if (GraphicsDevice.PresentationParameters.BackBufferWidth > GraphicsDevice.PresentationParameters.BackBufferHeight) { supportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight; } else { supportedOrientations = DisplayOrientation.Portrait | DisplayOrientation.PortraitUpsideDown; } } switch (orientation) { case UIDeviceOrientation.Portrait: if ((supportedOrientations & DisplayOrientation.Portrait) != 0) { _view.CurrentOrientation = DisplayOrientation.Portrait; GraphicsDevice.PresentationParameters.DisplayOrientation = DisplayOrientation.Portrait; TouchPanel.DisplayOrientation = DisplayOrientation.Portrait; } break; case UIDeviceOrientation.LandscapeLeft: if ((supportedOrientations & DisplayOrientation.LandscapeLeft) != 0) { _view.CurrentOrientation = DisplayOrientation.LandscapeLeft; GraphicsDevice.PresentationParameters.DisplayOrientation = DisplayOrientation.LandscapeLeft; TouchPanel.DisplayOrientation = DisplayOrientation.LandscapeLeft; } break; case UIDeviceOrientation.LandscapeRight: if ((supportedOrientations & DisplayOrientation.LandscapeRight) != 0) { _view.CurrentOrientation = DisplayOrientation.LandscapeRight; GraphicsDevice.PresentationParameters.DisplayOrientation = DisplayOrientation.LandscapeRight; TouchPanel.DisplayOrientation = DisplayOrientation.LandscapeRight; } break; case UIDeviceOrientation.FaceDown: if ((supportedOrientations & DisplayOrientation.FaceDown) != 0) { _view.CurrentOrientation = DisplayOrientation.FaceDown; GraphicsDevice.PresentationParameters.DisplayOrientation = DisplayOrientation.FaceDown; TouchPanel.DisplayOrientation = DisplayOrientation.FaceDown; } break; case UIDeviceOrientation.FaceUp: if ((supportedOrientations & DisplayOrientation.FaceUp) != 0) { _view.CurrentOrientation = DisplayOrientation.FaceUp; GraphicsDevice.PresentationParameters.DisplayOrientation = DisplayOrientation.FaceUp; TouchPanel.DisplayOrientation = DisplayOrientation.FaceUp; } break; case UIDeviceOrientation.PortraitUpsideDown: if ((supportedOrientations & DisplayOrientation.PortraitUpsideDown) != 0) { _view.CurrentOrientation = DisplayOrientation.PortraitUpsideDown; GraphicsDevice.PresentationParameters.DisplayOrientation = DisplayOrientation.PortraitUpsideDown; TouchPanel.DisplayOrientation = DisplayOrientation.PortraitUpsideDown; } break; case UIDeviceOrientation.Unknown: if ((supportedOrientations & DisplayOrientation.Unknown) != 0) { _view.CurrentOrientation = DisplayOrientation.Unknown; TouchPanel.DisplayOrientation = DisplayOrientation.Unknown; } break; default: break; } }); UIDevice.CurrentDevice.BeginGeneratingDeviceOrientationNotifications(); }
protected override void DrawScreen(SpriteBatch batch, DisplayOrientation displayOrientation) { level.Draw(batch); level.DisplayDebug(debugFont, batch); playerBar.Draw(batch); }
/// <summary> /// Handles input, performs physics, and animates the player sprite. /// </summary> /// <remarks> /// We pass in all of the input states so that our game is only polling the hardware /// once per frame. We also pass the game's orientation because when using the accelerometer, /// we need to reverse our motion when the orientation is in the LandscapeRight orientation. /// </remarks> public void Update(GameTime gameTime, KeyboardState keyboardState, GamePadState gamePadState, TouchCollection touchState, AccelerometerState accelState, DisplayOrientation orientation) { HandleCollision(); if (object.ReferenceEquals(this.GetType(), typeof(Spikes))) { ((Spikes)this).elapsedTimeOpen += Convert.ToSingle(gameTime.ElapsedGameTime.TotalSeconds); if (((Spikes)this).elapsedTimeOpen > ((Spikes)this).timeOpen) { ((Spikes)this).Close(); } } if (object.ReferenceEquals(this.GetType(), typeof(Lava))) { ((Lava)this).elapsedTimeOpen += Convert.ToSingle(gameTime.ElapsedGameTime.TotalSeconds); if (((Lava)this).elapsedTimeOpen > ((Lava)this).timeOpen) { ((Lava)this).Close(); } } if (object.ReferenceEquals(this.GetType(), typeof(Chomper))) { ((Chomper)this).elapsedTimeOpen += Convert.ToSingle(gameTime.ElapsedGameTime.TotalSeconds); if (((Chomper)this).elapsedTimeOpen > ((Chomper)this).timeOpen) { ((Chomper)this).Close(); } } if (object.ReferenceEquals(this.GetType(), typeof(Gate))) { ((Gate)this).elapsedTimeOpen += Convert.ToSingle(gameTime.ElapsedGameTime.TotalSeconds); if (((Gate)this).timeOpen == 0 && ((Gate)this).tileState.Value().state == Enumeration.StateTile.opened) { ((Gate)this).Opened(); } else if (((Gate)this).elapsedTimeOpen > ((Gate)this).timeOpen) { ((Gate)this).Close(); } } if (object.ReferenceEquals(this.GetType(), typeof(PressPlate))) { ((PressPlate)this).elapsedTimeOpen += Convert.ToSingle(gameTime.ElapsedGameTime.TotalSeconds); if (((PressPlate)this).elapsedTimeOpen > ((PressPlate)this).timeOpen & ((PressPlate)this).State == Enumeration.StateTile.dpressplate) { ((PressPlate)this).DePress(); } } if (object.ReferenceEquals(this.GetType(), typeof(Loose))) { if (((Loose)this).tileState.Value().state == Enumeration.StateTile.loose) { ((Loose)this).elapsedTimeOpen += Convert.ToSingle(gameTime.ElapsedGameTime.TotalSeconds); if (((Loose)this).elapsedTimeOpen > ((Loose)this).timeFall) { ((Loose)this).Fall(); } } } float elapsed = Convert.ToSingle(gameTime.ElapsedGameTime.TotalSeconds); tileAnimation.UpdateFrameTile(elapsed, ref _position, ref flip, ref tileState); }
protected internal override void SetSupportedOrientations(DisplayOrientation orientations) { }
private void SetDisplayOrientation(DisplayOrientation value) { if (value != _currentOrientation) { DisplayOrientation supported = GetEffectiveSupportedOrientations(); ScreenOrientation requestedOrientation = ScreenOrientation.Unspecified; bool wasPortrait = _currentOrientation == DisplayOrientation.Portrait || _currentOrientation == DisplayOrientation.PortraitDown; bool requestPortrait = false; bool didOrientationChange = false; // Android 2.3 and above support reverse orientations int sdkVer = (int)Android.OS.Build.VERSION.SdkInt; if (sdkVer >= 10) { // Check if the requested orientation is supported. Default means all are supported. if ((supported & value) != 0) { didOrientationChange = true; _currentOrientation = value; switch (value) { case DisplayOrientation.LandscapeLeft: requestedOrientation = (ScreenOrientation)ScreenOrientationAll.Landscape; requestPortrait = false; break; case DisplayOrientation.LandscapeRight: requestedOrientation = (ScreenOrientation)ScreenOrientationAll.ReverseLandscape; requestPortrait = false; break; case DisplayOrientation.Portrait: requestedOrientation = (ScreenOrientation)ScreenOrientationAll.Portrait; requestPortrait = true; break; case DisplayOrientation.PortraitDown: requestedOrientation = (ScreenOrientation)ScreenOrientationAll.ReversePortrait; requestPortrait = true; break; } } } else { // Check if the requested orientation is either of the landscape orientations and any landscape orientation is supported. if ((value == DisplayOrientation.LandscapeLeft || value == DisplayOrientation.LandscapeRight) && ((supported & (DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight)) != 0)) { didOrientationChange = true; _currentOrientation = DisplayOrientation.LandscapeLeft; requestedOrientation = ScreenOrientation.Landscape; requestPortrait = false; } // Check if the requested orientation is either of the portrain orientations and any portrait orientation is supported. else if ((value == DisplayOrientation.Portrait || value == DisplayOrientation.PortraitDown) && ((supported & (DisplayOrientation.Portrait | DisplayOrientation.PortraitDown)) != 0)) { didOrientationChange = true; _currentOrientation = DisplayOrientation.Portrait; requestedOrientation = ScreenOrientation.Portrait; requestPortrait = true; } } if (didOrientationChange) { // Android doesn't fire Released events for existing touches // so we need to clear them out. if (wasPortrait != requestPortrait) { TouchPanelState.ReleaseAllTouches(); } OnOrientationChanged(); } } }
private void ChangeOrCreateDevice(bool forceCreate) { // We make sure that we won't be call by an asynchronous event (windows resized) lock (lockDeviceCreation) { using (Profiler.Begin(GraphicsDeviceManagerProfilingKeys.CreateDevice)) { isChangingDevice = true; var width = game.Window.ClientBounds.Width; var height = game.Window.ClientBounds.Height; //If the orientation is free to be changed from portrait to landscape we actually need this check now, //it is mostly useful only at initialization actually tho because Window_OrientationChanged does the same logic on runtime change if (game.Window.CurrentOrientation != currentWindowOrientation) { if ((game.Window.ClientBounds.Height > game.Window.ClientBounds.Width && preferredBackBufferWidth > preferredBackBufferHeight) || (game.Window.ClientBounds.Width > game.Window.ClientBounds.Height && preferredBackBufferHeight > preferredBackBufferWidth)) { //Client size and Back Buffer size are different things //in this case all we care is if orientation changed, if so we swap width and height var w = preferredBackBufferWidth; preferredBackBufferWidth = preferredBackBufferHeight; preferredBackBufferHeight = w; } } var isBeginScreenDeviceChange = false; try { // Notifies the game window for the new orientation var orientation = SelectOrientation(supportedOrientations, PreferredBackBufferWidth, PreferredBackBufferHeight, true); game.Window.SetSupportedOrientations(orientation); var graphicsDeviceInformation = FindBestDevice(forceCreate); OnPreparingDeviceSettings(this, new PreparingDeviceSettingsEventArgs(graphicsDeviceInformation)); isFullScreen = graphicsDeviceInformation.PresentationParameters.IsFullScreen; game.Window.BeginScreenDeviceChange(graphicsDeviceInformation.PresentationParameters.IsFullScreen); isBeginScreenDeviceChange = true; bool needToCreateNewDevice = true; // If we are not forced to create a new device and this is already an existing GraphicsDevice // try to reset and resize it. if (!forceCreate && GraphicsDevice != null) { if (CanResetDevice(graphicsDeviceInformation)) { try { var newWidth = graphicsDeviceInformation.PresentationParameters.BackBufferWidth; var newHeight = graphicsDeviceInformation.PresentationParameters.BackBufferHeight; var newFormat = graphicsDeviceInformation.PresentationParameters.BackBufferFormat; var newOutputIndex = graphicsDeviceInformation.PresentationParameters.PreferredFullScreenOutputIndex; GraphicsDevice.Presenter.Description.PreferredFullScreenOutputIndex = newOutputIndex; GraphicsDevice.Presenter.Description.RefreshRate = graphicsDeviceInformation.PresentationParameters.RefreshRate; GraphicsDevice.Presenter.Resize(newWidth, newHeight, newFormat); // Change full screen if needed GraphicsDevice.Presenter.IsFullScreen = graphicsDeviceInformation.PresentationParameters.IsFullScreen; needToCreateNewDevice = false; } catch { // ignored } } } // If we still need to create a device, then we need to create it if (needToCreateNewDevice) { CreateDevice(graphicsDeviceInformation); } if (GraphicsDevice == null) { throw new InvalidOperationException("Unexpected null GraphicsDevice"); } // Make sure to copy back coolor space to GraphicsDevice GraphicsDevice.ColorSpace = graphicsDeviceInformation.PresentationParameters.ColorSpace; var presentationParameters = GraphicsDevice.Presenter.Description; isReallyFullScreen = presentationParameters.IsFullScreen; if (presentationParameters.BackBufferWidth != 0) { width = presentationParameters.BackBufferWidth; } if (presentationParameters.BackBufferHeight != 0) { height = presentationParameters.BackBufferHeight; } deviceSettingsChanged = false; } finally { if (isBeginScreenDeviceChange) { game.Window.EndScreenDeviceChange(width, height); } currentWindowOrientation = game.Window.CurrentOrientation; isChangingDevice = false; } } } }
internal void SetSupportedOrientations(DisplayOrientation orientations) { supportedOrientations = orientations; }
/// <summary> /// Handles input, performs physics, and animates the player sprite. /// </summary> /// <remarks> /// We pass in all of the input states so that our game is only polling the hardware /// once per frame. We also pass the game's orientation because when using the accelerometer, /// we need to reverse our motion when the orientation is in the LandscapeRight orientation. /// </remarks> public void Update(GameTime gameTime, KeyboardState keyboardState, GamePadState gamePadState, TouchCollection touchState, AccelerometerState accelState, DisplayOrientation orientation) { float elapsed = Convert.ToSingle(gameTime.ElapsedGameTime.TotalSeconds); // TODO: Add your game logic here. sprite.UpdateFrame(elapsed, ref _position, ref flip, ref spriteState); if (IsAlive == false) { DropDead(); return; } //bool thereIsKid = false; foreach (Sprite s in SpriteRoom.SpritesInRoom()) { switch (s.GetType().Name) { case "Player": if (true) { if (s.IsAlive == false) { break; // TODO: might not be correct. Was : Exit Select } //thereIsKid = true; if (s.Position.CheckOnRow(Position)) { if (s.Position.CheckOnRowDistancePixel(Position) >= 0 & s.Position.CheckOnRowDistancePixel(Position) <= 70 & Alert == true & spriteState.Value().state == Enumeration.State.strike) { if (spriteState.Value().Name == Enumeration.State.strike.ToString().ToUpper()) { //check if block if (s.spriteState.Value().Name != Enumeration.State.readyblock.ToString().ToUpper()) { spriteState.Value().Name = string.Empty; s.Splash(true, gameTime); //Splash splash = new Splash(SpriteRoom, Position.Value, graphicsDevice, SpriteEffects.None, true); //Maze.sprites.Add(splash); s.Energy = s.Energy - 1; s.StrikeRetreat(); } else { System.Console.WriteLine("P->" + Enumeration.State.readyblock.ToString().ToUpper()); //blocked } } if (s.Energy == 0) { Fastheathe(); } } Alert = true; //Chenge Flip player.. if (Position.X < s.Position.X) { flip = SpriteEffects.None; } else { flip = SpriteEffects.FlipHorizontally; } Advance(s.Position, flip); } else { Alert = false; } break; // TODO: might not be correct. Was : Exit Select } default: break; // TODO: might not be correct. Was : Exit Select } } if (Alert == false) { Stand(); } //Ready(); else { Stand(); } }
protected static DisplayOrientation SelectOrientation(DisplayOrientation orientation, int width, int height, bool allowLandscapeLeftAndRight) { if (orientation != DisplayOrientation.Default) { return orientation; } if (width <= height) { return DisplayOrientation.Portrait; } if (allowLandscapeLeftAndRight) { return DisplayOrientation.LandscapeRight | DisplayOrientation.LandscapeLeft; } return DisplayOrientation.LandscapeLeft; }
/// <summary> /// Updates all objects in the world, performs collision between them, /// and handles the time limit with scoring. /// </summary> public void Update( GameTime gameTime, KeyboardState keyboardState, GamePadState gamePadState, TouchCollection touchState, #if WINDOWS_PHONE AccelerometerState accelState, #endif DisplayOrientation orientation) { // Pause while the player is dead or time is expired. if (!Player.IsAlive || TimeRemaining == TimeSpan.Zero) { // Still want to perform physics on the player. Player.ApplyPhysics(gameTime); } else if (ReachedExit) { // Animate the time being converted into points. int seconds = (int)Math.Round(gameTime.ElapsedGameTime.TotalSeconds * 100.0f); seconds = Math.Min(seconds, (int)Math.Ceiling(TimeRemaining.TotalSeconds)); timeRemaining -= TimeSpan.FromSeconds(seconds); score += seconds * PointsPerSecond; } else { timeRemaining -= gameTime.ElapsedGameTime; Player.Update( gameTime, keyboardState, gamePadState, touchState, #if WINDOWS_PHONE accelState, #endif orientation); UpdateGems(gameTime); // Falling off the bottom of the level kills the player. if (Player.BoundingRectangle.Top >= Height * Tile.Height) { OnPlayerKilled(null); } UpdateEnemies(gameTime); // The player has reached the exit if they are standing on the ground and // his bounding rectangle contains the center of the exit tile. They can only // exit when they have collected all of the gems. if (Player.IsAlive && Player.IsOnGround && Player.BoundingRectangle.Contains(exit)) { OnExitReached(); } } // Clamp the time remaining at zero. if (timeRemaining < TimeSpan.Zero) { timeRemaining = TimeSpan.Zero; } }
/// <summary> /// Updates the screen orientation. Filters out requests for unsupported orientations. /// </summary> internal void SetOrientation(DisplayOrientation newOrientation, bool applyGraphicsChanges) { DisplayOrientation supported = GetEffectiveSupportedOrientations(); // If the new orientation is not supported, force a supported orientation if ((supported & newOrientation) == 0) { if ((supported & DisplayOrientation.LandscapeLeft) != 0) newOrientation = DisplayOrientation.LandscapeLeft; else if ((supported & DisplayOrientation.LandscapeRight) != 0) newOrientation = DisplayOrientation.LandscapeRight; else if ((supported & DisplayOrientation.Portrait) != 0) newOrientation = DisplayOrientation.Portrait; else if ((supported & DisplayOrientation.PortraitDown) != 0) newOrientation = DisplayOrientation.PortraitDown; } DisplayOrientation oldOrientation = CurrentOrientation; SetDisplayOrientation(newOrientation); TouchPanel.DisplayOrientation = newOrientation; if (applyGraphicsChanges && oldOrientation != CurrentOrientation && _game.graphicsDeviceManager != null) _game.graphicsDeviceManager.ApplyChanges(); }
protected virtual void OnOrientationChanged(DisplayOrientation orientation) { }
/// <summary> /// Sets the parameters required by this template when running in <see cref="TemplateGeneratorParameters.Unattended"/> mode. /// </summary> public static void SetParameters([NotNull] SessionTemplateGeneratorParameters parameters, [NotNull] IEnumerable <SelectedSolutionPlatform> platforms, GraphicsProfile graphicsProfile = GraphicsProfile.Level_10_0, bool isHDR = true, DisplayOrientation orientation = DisplayOrientation.Default, IEnumerable <UDirectory> assets = null) { if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } if (platforms == null) { throw new ArgumentNullException(nameof(platforms)); } parameters.SetTag(PlatformsKey, new List <SelectedSolutionPlatform>(platforms)); if (assets != null) { parameters.SetTag(AssetsKey, new List <UDirectory>(assets)); } parameters.SetTag(IsHDRKey, isHDR); parameters.SetTag(GraphicsProfileKey, graphicsProfile); parameters.SetTag(OrientationKey, orientation); }