Tuesday, October 25, 2022
HomeGame DevelopmentResponsive2D Alignment Extension - Cocos Creator

Responsive2D Alignment Extension – Cocos Creator


Hello, I’ve labored on an extension for a couple of weeks and it’s time to share it with you.

With this plugin, you’ll be able to align 2D nodes for various display varieties. It’s helpful particularly for ui components.

I put right here GitHub hyperlink

Hope you prefer it.

Earlier than Begin

Please rename your canvas node title as “Canvas” within the editor.

Find out how to Set up

On the menu

  • Extension → Extension Supervisor

  • Open Venture panel from Extension Supervisor

  • Press + icon

  • Select zip file

  • After set up restart editor

Find out how to Use

This extension works in actual time. While you change one thing on the part, you’ll be able to see modifications immediately on the editor.

1- Width Ratio

Scales sport object with entered worth. For instance, if the worth equals 1, so the sport object width will probably be equal to display dimension.

2- Peak Ratio

Identical with width ratio, on this case the sport object top modifications.

3- Ratio Kind

Choices are ‘min, max and stretch’

min

Chooses minimal worth between width and top ratio and apply scale to sport object.

max

Chooses most worth between width and top ratio and apply scale to sport object.

stretch

Scales sport object seperately for width and top ratios.

4- Referance Node

Initially sport objects align self acoording to display dimensions. If a referance node utilized so the sport object considers referance node remodel values.

5- Alignment

The all display is split into sections. The yellow half that you just see on the picture is the chosen alignment (heart – heart) which suggests the sport object will probably be positioned on the heart of the display. Select completely different sections to position sport object completely different areas and we are going to use spacing to provide offset to the sport object.

6- Observe Node

Enabling this selection disables alignment and the sport object observe chosen node place.

7- Horizontal House

This works with Alignment and Observe Node. This spec contains 8 choices. These are:

%

Offers area to the sport object utilizing the % of accessible area. For instance selecting 50% strikes the sport object proper as a lot as half of the display width.

8- Ratio Kind

px

Offers area utilizing pixel worth

self

Offers area by calculating sport object self width. For instance If 100% setted, so the sport object will probably be moved as a lot as self width

left

Offers area by calculating left referance node width. For instance If 100% setted, so the sport object will probably be moved as a lot as left referance node width

proper
high
backside

Identical factor goes for different referance nodes

observe

And similar factor goes for adopted node that I defined within the entry 6

9- Vertical House

That is vertical spacing, it’s similar with Horizontal House. The one distinction is spacing vertically.

10- Flip X

Flips the sport object horizontally and the flip y is flips the sport object verticalls as its title explains the case.

11- Portrait Menu

Settings for portrait orientation

12- Panorama Menu

Settings for panorama orientation

13- Settings Menu

Common settings

14- Rotate Display screen

Rotates editor gameplay space so we will set issues for each portrait and panorama orientations.

15- Change Dimension

Modifications gameplay space’s dimension. At the moment we’ve 3 completely different gadget. However you’ll be able to add completely different gadget dimensions within the script.

16- Allow Panorama

If this selection shouldn’t be enabled, the sport object makes use of portrait values for the panorama and whether it is enabled so you’ll be able to set panorama alignment for the sport object.

17- Paste Portrait

Rapidly copy and paste portrait settings.

18- Resize Frequency

That is contains 3 choices that are:

ON_WINDOW_RESIZE

Calculation is made for every display dimension change occasion, like switching between portrait and panorama orientations.

ONCE

Calculation is made for less than as soon as.

ALWAYS

Calculation is made within the replace methodology.

19- Calculate Content material Measurement

In case you have father or mother node and this node has little one nodes, so place little one nodes within the editor and calculate the father or mother dimensions with this selection after which untick this selection. The primary objective is getting remodel values of the father or mother node so we will align father or mother with proper proprtions.

20- Positioning from Anchor

Usually extension positions the sport object by utilizing its edge factors. If this selection is enabled, the sport object will probably be aligned from it’s anchor factors.

For Questions

Discord: agonima#2526

Pattern Video

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments