fantomEngine - WP8 orientation issues
Monkey Forums/User Modules/fantomEngine - WP8 orientation issues
| ||
Hi, I've just started using fantomEngine and when I came to test the game on windows phone 8 the view was messed up when rotating the screen. In portrait mode the tiled map example project is correctly scaled to fit in letter box mode, then when I switch to landscape the map appears half way down the screen with gui layers off screen. Everything seems to scale correctly but the camera offsets are not modified to make everything appear on screen correctly. Does this not work on wp8? |
| ||
Have you tested it on the latest monkey (v72/v73a?) I think this was fixed on v72. |
| ||
Hi SLotman I'm using version 73a and the problem persists. I don't think this is an issue with Monkey, autofit works like a charm, it's a problem with fantomEngine. If I fix the orientation to landscape in VS before deploying it works OK, it's only when the orientation changes. I currently doing tests with the tiled example that comes with fantomEngine to make sure that it's not a problem with my code. |
| ||
If you change the orientation during the execution of the app, you need to call SetCanvasSize again. |
| ||
Hi MikeHart, OK, that sounds reasonable. So if i check the screen size in the update loop then call the set canvas size if its changed that should do it right, or is there a better way of doing this? Although, thinking about it, the canvas size shouldn't change, I would want to keep the canvas size but have it scale correctly. Would calling set canvas size with the same values account for this? |
| ||
Yes, each update call or at least every so often. You don't need to set a different canvas size. All what SetCanvasSize does is set the virtual canvas size for fE and calculate the aspect ratios plus the camera offset according the the give mode and the actual size of the device canvas. So it would only work if the canvas size values of the device change when you rotate the device. If the values for DeviceHeight() and DeviceWidth() doesn't change according to the ration, fE can't do anything about it. But as you say that AutoFit works, then fE should handle it just fine. |
| ||
Ok, you need a little modified version of SetCanvasSize to make it work when you rotate the device:Method SetCanvasSize:Void(width:Int, height:Int, canvasmode:Int = ftEngine.cmLetterbox) screenWidth = DeviceWidth() screenHeight = DeviceHeight() Local dx:Int = screenWidth - width Local dy:Int = screenHeight - height If canvasmode > 3 Or canvasmode < 0 Then Error ("~n~nError in method ftEngine.SetCanvasSize.~n~nInvalid mode value = "+canvasmode) canvasWidth = width canvasHeight = height If canvasmode = 0 Then scaleX = screenWidth / canvasWidth scaleY = screenHeight / canvasHeight Elseif canvasmode = 1 Then autofitX = (screenWidth - canvasWidth)/2 autofitY = (screenHeight - canvasHeight)/2 Elseif canvasmode = 2 Then scaleX = screenWidth / canvasWidth scaleY = screenHeight / canvasHeight If scaleX > scaleY Then scaleX = scaleY Else scaleY = scaleX Endif autofitX = ((screenWidth - (canvasWidth*scaleX))/2) autofitY = ((screenHeight - (canvasHeight*scaleY))/2) Endif End |
| ||
Excellent, thank you very much, it is appreciated. With this change in place fantomEngine will be a formidable package. |
| ||
...With this change in place fantomEngine will be a formidable package. thanks, I guess I can stop working on it then :-) |