Layout size to fit SmartPhones

Discussion and feedback on Construct 2

Post » Tue Jun 14, 2011 12:54 pm

Djordhan, if you position and scale everything in the layout depending on the WindowWidth and WindowHeight expressions, it should fit any device screen. Then, you can also test it works in your browser window on a desktop, just by adjusting the window size.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,564

Post » Tue Jun 14, 2011 5:42 pm

It seems to work fine.

Tips: Don't forget to set the objects' position to windowWidth / 2 and windowHeight / 2 otherwise sprites will stretch outside the screen.

It solves most problems but I don't think the same game would look good on iPhone 3 at 320x480 and on iPhone4 at 640x920, everything will look quite stretched, specially if you have pixel art.
B
6
S
2
G
1
Posts: 122
Reputation: 1,194

Post » Tue Jun 14, 2011 5:49 pm

The best thing to do is probably draw everything for the higher resolution (640x920), and scale it down for smaller displays. That always looks better than up-scaling low resolution graphics.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,564

Post » Tue Jun 14, 2011 6:08 pm

That is so logic I didn't even think about that.

Fact is that it's always gonna be a problem when doing html5 games for mobiles when you want to support iPhone and iPad, and the future iTable and iWall.. C2 or not. I'm gonna dig a little on other html5 developer forum and keep you posted :P
B
6
S
2
G
1
Posts: 122
Reputation: 1,194

Post » Wed Oct 19, 2011 7:53 am

Hi Djordhan

Did you ever find a solution for the different mobilescreens ???
pls let me know


I stucked with my project, but would maybe do the ugly one..
having a script to detect screensize and the redirect

The bad thing is that I have to design more versions in C2

Cheers
flemming
B
23
S
12
G
10
Posts: 322
Reputation: 7,380

Post » Wed Oct 19, 2011 2:13 pm

You can try playing with the WindowWidth and WindowHeight expressions (which returns the width and height of the current device's display), and the Set Layer Scale action (which allows you to zoom an entire layout in and out).
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,564

Post » Wed Oct 19, 2011 2:46 pm

Hi Ashley

Could you please tell be more -   in how to use these expressions

would like to give it a go :-)

thanks
B
23
S
12
G
10
Posts: 322
Reputation: 7,380

Post » Wed Oct 19, 2011 6:12 pm

I haven't touched C2 for a while now but I assume that you can build your application for a specific screen size then check the ratio of the current device screen size, then apply this ratio with the SetLayerScale:

Example:

Let's say your application runs in 1000x500 by default, then the device running your game is 1200x600, then you get a 1.2 ratio. You can probably use the SetLayerScale with the 1.2 ratio to resize your game..

I guess it would look like something like this:

SetLayerScale(WindowWidth/DefaultWidth,WindowHeight/DefaultHeight)

It's probably not working exactly like that in C2 but that's the idea.
B
6
S
2
G
1
Posts: 122
Reputation: 1,194

Previous

Return to Construct 2 General

Who is online

Users browsing this forum: Mirlas and 14 guests