I am new to Android development. I sent my app for testing on a couple of devices and a couple were fine, but a couple had the game half way off the screen. In the game scene everything is fine so what could be causing this in some devices?
I am using one main camera set to orthographic and it is a simple 2d game.
I guess one of my mistakes was not using the canvas properly and so I will make improvements, but why would this be like this in the game scene where I cannot use a canvas? Do I have to fix the position of main camera also?
Thankyou for help with this.
Try playing around with your canvas' screen match mode. I would try the expand or shrink option. This is pretty self explanatory, it will either shrink or expand your canvas to match the width or the height (depending on your settings for the canvas) of your display. If you're stuck, take a look at the doc for the canvas:
http://docs.unity3d.com/Manual/script-CanvasScaler.html
And the last thing is to play around with your UI elements' anchor positions. Here's the doc for the anchor positions:
http://docs.unity3d.com/Manual/UIBasicLayout.html
Hope this helps!
Related
I am working on my first VR project, in which I am displaying satellite data inside of a sphere. The camera/observer is placed in the middle of the sphere and "looks up" at the satellite data, which is rendered in all directions. I am doing this under Unity 2021 using the latest Cardboard SDK and running it on a Pixel-3 on Android 12. After some tinkering, I managed to get the scene to render, but the observer is MUCH too close to the scene. I am aware that the FOV is fixed by the device, but is seems to me that I should be able to scale the scene to "zoom out". However, nothing I have tried works, including the following;
Simply changing the size of the sphere (which is just a single "flip-normalled" object)
Changing the camera parameters (Note: I now understand that these have zero effect in VR, as the device sets the FOV).
Placing the camera object, embedded in an XRRig prefab in my case, inside an arbitrary "GameObject" and re-scaling the object (as specified here)
As in 3, but placing every object inside the GameObject
None of these have any effect on the eventual scene as built on the device. I am at a loss. Surely what I am attempting is possible? I really just want a tiny observer, i.e. to make the "sky" seem much farther away. Any/all help appreciated.
Cheers.
Perhaps you should make the satellites, or the images, smaller when rendering them to the sphere. Just scaling the sphere itself will probably just make everything larger, or smaller, to match the size of the sphere.
I am using LibGdx to develop a game. For Now I am not using scene2D. I am struck up in increasing the levels of the game as I do not have the scrolling screen.
I like to design a a scrolling screen as it is in many games which are level based (for ref, lets say Candy crush). Could you please point me a example on how to have such a scrolling screen to show a bigger area where I can show many levels.
Thanks is Advance !
Using the Scene2D function is not necessary for this and is more for GUI implementation and different screens. The Scroll pane really shines when creating reading content that does not fit your phone. I do advice to start learning Scene2D to create MenuScreens and UI though.
What Candy Crush "simply" does is having multiple backgrounds that are placed next to each other and tile seamlessly. They use buttons in the correct place for levels. By dragging a finger across the screen the camera will move in that direction. For the movement from one level to the next there is probably something like a spline in play.
It is important only to draw the background tiles and buttons that are actually visible on the screen if you have many. Since these have fixed positions and you know your camera area and position you can calculate what to draw and what not. Just drawing everything each frame is likely to slow down your fps.
You can do a search on:
Tilemaps, for you backgrounds but you probably want them in just one direction so a simple 1D array would suffice.
Dragging, to move your camera. Here I gave a basic explanations on how I do it.
Splines, are a bit tougher and you do not really need them. They could be used to animate or move something along a curve.
Thats all, expecting you know how to create something like a button (click a sprite).
I'm making a new Android Game with LibGDX, a platformer but I'm having issues with TMX (Tiled) maps. I read a lot about tiles gaps problems with LibGDX but I can't make it work well.
Here is my problem: sometimes, when the character moves, I can see for on each tiles the end of the previous tile on the Tileset, in full screen on my computer it works well most of the time, but when I set the size of the window to the resolution of my smartphone (800x480px) that won't work.
Here's a video of this problem:
https://www.youtube.com/watch?v=IXaoE_YNpuA&list=UUE3Ty03UMwTh3hNIKx2Dmmw
And here's my tileset:
Have you got an idea about what can solve this problem ?
This is because of the blending that happens when you're scaling down the image (or rendering it at sub-pixel positions). To avoid it, you can add a 2-pixel spacing between your tiles and make sure the pixels in this space match the colour of the neighbouring tile edges.
Alternatively, try to disable the blending, but I can't tell you how to do that in LibGDX.
I'm writing an Android and iOS engine in C++ and currently focusing on Android with the NDK.
I'd like to render to a viewport of a smaller size (say 600x360) and automatically upscale this to the native rez (say 800x480.) Currently the smaller viewport displays in a lower corner of my screen with black regions.
My problem is I don't know of a simple way to do this transparently using the NDK. There is a GLSurfaceview.setScaleX (and Y) function in API level 11, which would be perfect, but doesn't exist in API level 9, which I am targeting. Another bad solution is to render to a FBO and blit that to the screen as a final step.
I am considering simply story a scaling matrix and asking the user of the engine (for now just me) to always multiply vertices by this when drawing to the screen. This would be similar to using glPushMatrix.
I searched for a while and couldn't find a good solution. Does anyone know how to help?
What you can do is get the SurfaceHolder from GLSurfaceView, GLSurfaceView.getHolder() and then set the resolution you desire by calling SurfaceHolder.setFixedSize(width, height).
In my case the GLSurfaceView has a FrameLayout root which fills the screen, I am not sure if thats required - I have it because I add other elements on top - but if you set the size and it doesnt fill the screen then you know what's missing!
Using a FrameBuffer is also a valid way and you could draw some cool effects with it as well, the way above is just faster when the only thing you want to do is scale the rendering down (or possibly up? I haven't tried).
I am making the classic AR app for Android.
I am using a SurfaceView to show the camera.
I want to know, how I put things over it... Currently I am using widgets, but they have two issues:
First, they are slow.
Second, you cannot rotate them in 1.5 without using view animation, and noone I asked so far (here, forums, google, irc...) knows how view animation work, so I am failing to make the view animation work in sync with the custom view that put widgets over the camera (resulting in flickering).
Thus I decided to change the method of putting things on the screen, so what other ways exist? (note I am bound to Android 1.5)
Seemly it cannot be done easily, but I could put a image and rotate it easily using Matrix.
I basically placed on layout over the preview a ImageView, then I used setMatrix to a rotation matrix, and voilá, I got a rotated image that works in 1.5
You must use OpenGL for drawing Objects over your SurfaceView.