Gamekit multiplayer and different screen sizes - swift

I am very new to gamekit, so I am starting with a basic game. 2 players on the screen and allow them to just move around at this point.
I am testing the game with an ipad and a phone, so I am quickly realizing the ipad user has a lot more real estate instead of the same space being resized.
How do I setup the level to be the same amount of space on any device, but just magnified accordingly?

Try this for all the nodes that you want to be resized use the .setScale() method:
let scale = frame.width/667
node.setScale(scale)
667 is the approximate width of an iPhone 6. Feel free to play around with the number 667 to get the right magnification.
Basically what this does is it scales the node according to the size of the screen.
Note: Scaling may decrease resolution of any sprites used.

Related

Unity Viewport size to Full HD?

at the moment I start with Unity in 2D development for android. Before I develop in Unity i develop with LibGDX where I can the Viewport to a static screen resolution at 1080 * 1920, if the game starts on a smaller device for example 480 * 800 the game still looks pretty good. In Unity when I use a Orthographics Camera and set the width to 1080 and the height to 1920 it looks like a equal long quadrate and not portrait.
How can I use a static Camera which the Viewport is 1080 * 1920 and for other devices unity self charge the resolution for the game?
Sorry for my bad english :(
greetings coco07!
You can't. You're thinking about 2D engines. Unity is a 3D engine with a 2D extension (sort of). You set your camera up (doesn't matter what orthographic size you use), and it gets scaled to the viewport of the device it's running on. the size you set is the size of the viewport, in world units, along the y axis of the device's display. The width is set automatically based on the device's aspect ratio. You can see this by resizing the game window in unity. Doing that causes the visualization of the camera's bounds to change. To create a static camera, you'd have to manually add black borders around the edges (or at least I think you do), OR, better yet, create your game in a manner that runs on all aspects. You should consider aspect ratios between 4:3 and 16:9 for landscape and 3:4 to 9:16 for portrait games. This is specially important since many recent devices use on-screen system buttons (such as the google nexus and Xperia Z series) which means you get an aspect ratio of a little bit less that 16:9 (or a bit more, on tablets). This doesn't sound like much, but if you down-scale a 16:9 image to fit on those devices' screens, it looks ugly as hell.

Calculate the distance between the iPhone and a door, knowing their physical widths

I have this scenario:
I know the physical (not only in pixel) size of the screen of the iPhone.
Also I know the width of a door.
Now, if I have the iPhone camera on (with UIImagePicker or whatever), and I am in the position where the width of the door fits perfectly in the width of the camera, and the iPhone stands perfectly vertical, is it possible to know the distance between the iPhone and the door?
It would depend on the camera specs which vary between devices. For this reason I would try to sample some data with a ruler - for instance take a 3' wide plank, align the edges perfectly and measure distance. Do this with varying widths on different devices and you'll have a formula per device (basic algebra)

how to make my game run on different devices with various resolutions?

I'm developing a game for 480*800 resolution screen,but now I want to run it on all other screens I tried to run on 7" screen but my background image and even sprite position are out of order.Can anyone please suggest me with some examples about how to make my game compatible with different screen resolutions.
I used the below code but that was of no use.I have seen somewhere that by using FillResolutionPolicy() along with the below code andengine sets automatically for different screens but I did not notice any change ,so please help me in solving it.
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics)
CAMERA_WIDTH = metrics.widthPixels()
CAMERA_HEIGHT = metrics.heightPixels()
FillResolutionPolicy automatically scales everything depending on your screensize.
Camera camera = new Camera(0, 0, 480, 880);
EngineOptions engineOptions = new EngineOptions(true, ScreenOrientation.PORTRAIT_FIXED, new FillResolutionPolicy(), this.camera);
This is what I use, and if I start the game on a bigger device, everything is scaled automatically.
FillResolutionPolicy is probably exactly what you need.
(The code above might not be 100% accurate as I canĀ“t access my actual code right now)
FillResolutionPolicy() is just for the black stripe you have either left/right or top/bottom depending on the screens aspect-ratio. see this post in the andengine forum to read about resolution policy.
the camera width/height has nothing to do with the devices real resolution, since it's projected to either the devices height or the devices width (depending on the aspect ratio of your camera settings & the aspect ratio of the device). there is only one point where the DisplayMetrics are useful - get the screens density/max resolution to load res-depending sprites (like: like higher density, load larger sprites) but that's not your problem atm.
the games i tested andengine with, are all resolution independent and can be run on 4, 7 or 10 inch displays with different resolutions without any addition/code changes.
i think it's more like a coding mistake where you added sprites and background image to the scene. for example, by recalculating CAMERA_WIDTH/_HEIGHT with metrics and sprite positions that depend on the CAMERA_WIDTH/_HEIGHT, you mix up the sprite positions with the devices resolution and everything looks a bit out of order. perhaps you add some code, and i can edit my answer pointing you in the right direction.

How to handle resolution change 320x480 => 640x960 related to gameplay

I have decided to have 2 set of images for my iPod game. One with 320x480 and the other for the retina one. I can switch happily between them but this forces me to add extra code to handle the change in resolution.
My game is played in screen space on a grid, so, if I have 32 pixel tiles, I will have to use 32 offsets in low res and 64 in retina (because of doubling resolution). For a simple game this can be no problem, but what about other more complex games? How do you handle this without hardcoding things depending on the target resolution.
Of course an easy way to bypass this is just releasing a 320x480 version an let the hardware upscale, but this is not what I want because of blurry images. I'm a bit lost here.
If you have to, you can do the conversion from points to pixels (and vice versa), easily by either multiplying or dividing the pixel/point position with the contentScaleFactor of your view. However, normally this is done automatically by you if you just keep it to using points instead of pixels.
This is automatic. You only need to add image files suffixed '#2x' for the retina resolution.
Regarding pixels, from your program you work in points which are translated to pixels by the system. Screen dimensions are 320x480 points for iphone retina and non-retina.

Cocos2d : tile maps VS 1 giant image

I have been doing some reading and tutorials on tile maps in cocos2d, but what i want is to have a large graphic map, not made up of tiles that the user can drag around. so my question is this.
Is it going to cause performance issues to have a large map, (this will be on the ipad so maybe x4 the screen size)?
The maximum texture size you can have is 2048x2048 for any device above the iPhone 3G (This includes all iPads, although it may be larger on the iPhone 4S, but I doubt it). You can find tons of links on google by a simple search of iphone max texture size. That means that the largest image you can have is between 4-6 iPad screens. If this is enough for you, great! If not, you'll have to tile the screen anyways, regardless of the size of your tiles. Hope that Helps!