Align to sides issue on Android and CocoonJS

Get help using Construct 2

Post » Mon Feb 25, 2013 5:47 pm

Hello,
how, via code, you can align the 4 squares in .capx at http://bit.ly/ZEQVik to the 4 sides of the square?

I need this:


I need that the 4 squares remains attached to the 4 sides even if I resize the screen.

Someone can tell me how I can do this, please?

Regards,
ghale.ghale2013-02-25 21:58:39
B
10
S
4
G
4
Posts: 42
Reputation: 3,091

Post » Mon Feb 25, 2013 6:12 pm

if you set their hot spots to the corner of each sprite that is relative to where you want the sprite to be (ie the top left sprite would have the hot spot in the top left)

then is it not a case of saying
sprite(top left) position 0,0
sprite (top right) position (screen width,0)
sprite (bottom left) position screen height,0
sprite (bottom right) position (screen width,screen height)

August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
59
S
30
G
34
Posts: 1,194
Reputation: 23,767

Post » Mon Feb 25, 2013 6:32 pm

@RamPackWobble
Thanks for the reply...

Like this?
I've not achieved the solution!
B
10
S
4
G
4
Posts: 42
Reputation: 3,091

Post » Mon Feb 25, 2013 6:58 pm

sorry sprite 3 should be (0,screen height) not as I had above
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
59
S
30
G
34
Posts: 1,194
Reputation: 23,767

Post » Mon Feb 25, 2013 7:01 pm

@RamPackWobble

I've done this: Alignment_03.capx

It works.

It this a good solution?
B
10
S
4
G
4
Posts: 42
Reputation: 3,091

Post » Mon Feb 25, 2013 7:09 pm

Or you could use the anchor behavior.
B
54
S
28
G
18
Posts: 1,520
Reputation: 25,020

Post » Mon Feb 25, 2013 7:24 pm

Really depends on what it is for! if you want to do it with events and not behaviors, and the origin is in the center, you can do:

Spawn BoxObj
Set position to X: (Self.Width/2), Y: (Self.Height/2)
Spawn BoxObj
Set position to X: WindowWidth-(Self.Width/2), Y: (Self.Height/2)
Spawn BoxObj
Set position to X: (Self.Width/2), Y: WindowHeight-(Self.Height/2)
Spawn BoxObj
Set position to X: WindowWidth-(Self.Width/2), Y: WindowHeight-(Self.Height/2)
B
51
S
13
G
8
Posts: 194
Reputation: 7,311

Post » Mon Feb 25, 2013 8:11 pm

Ok, I've tried with anchor behavior.

On PC, all is ok.
But with CocoonJS and Android, I see the buttons that are not aligned and a flicker effect when I change Layout.
HTML Example (working good): http://bit.ly/X6KcLu
APK for Android signed with debug key(not working good): http://bit.ly/13bdEnq
ZipFile for use with CocoonJS Launcher on Android: http://bit.ly/XUyT7Jghale2013-02-25 20:18:18
B
10
S
4
G
4
Posts: 42
Reputation: 3,091

Post » Tue Feb 26, 2013 9:49 am

I've written to CocoonJS, I hope they reply...
I need a solution, I've invested some money in my project and I can't stop it for alignment issues!
B
10
S
4
G
4
Posts: 42
Reputation: 3,091

Post » Tue Feb 26, 2013 11:25 am

You need to use the viewport functions.

CocoonJS adjusts the screen for a few ticks, so best is to check if it has changed and if it has then set the positions again.

On start of layout:

Then set your x,y of the images to (0,0); (0,ScreenHeight); (ScreenWidth,0);(ScreenWidth,ScreenHeight).

Then every tick you have a condition to check if the variable is still equal to the viewport function.
if it has changed then redo this:
Then set your x,y of the images to (0,0); (0,ScreenHeight); (ScreenWidth,0);(ScreenWidth,ScreenHeight).
B
22
S
7
G
3
Posts: 189
Reputation: 4,270

Next

Return to How do I....?

Who is online

Users browsing this forum: flemmig, GSquadron, jeffige, MisterAqua, Nifl, paala and 26 guests