1. Button:
button is one of the most commonly used control types in the game, control the user click the event switch, have normal, press, disable three states, you can set the style and text for them.
Usage Scenarios
The use of buttons is very common, as an example of the main scene examples in the official example, the contents of the frame are made up of button controls
In your project, the levels, diamonds, and coins above the interface can also be made up of button controls that jump to the appropriate interface when the user touches it.
There are a number of button control properties, in addition to the general properties, including the dimension attributes and some attribute properties, and we'll show you how to better use this control from several scenarios that often use button controls
Scenario 1: Modifying the button background, setting the button down effect and disabling effects
The button has three states, each of which can be defined by a picture. For example, the implemented button
You only need to add a button to the canvas, select the button control, and in the Attributes section of the Properties panel, the current style resource for the button control is displayed, you can double-click to modify the button control's properties, or you can drag the picture asset onto the current style resource to replace it with the new resource. We set a normal and pressed state for the button so that when you touch the button in the game, the button automatically switches to the pressed state of the picture. If necessary, you can also set the disabled state for the button.
In addition, new resources can be added via the button control's right-click menu.
Scenario 2: When using a button, you need to set the text on the button
Sometimes when we set the button style, we also want to set the text of the button, you can use the Modify button text feature to achieve this requirement. You can customize the color, font, and size of the button text. Modify the button text by simply selecting the button, modifying the Text property in the property area, or by clicking "menu-Edit Text" or "double-click" To change the text pop-up window.
Scenario 3: In-game, do not want the button to respond to User touch events
Ability to set whether the button is enabled in the Properties panel or the right-click menu, the button is disabled and will not respond to touch events in the final game.
2. check box:
A check box is an underlying control that can select multiple items at the same time, and you can set his various styles, as well as the selected state.
Usage Scenarios
check box is most commonly used in the game login interface, "Remember the user name" and "Remember Password", I believe you must often see.
There are also some game settings, which control whether music is enabled or not, and is usually a check box control. There are a number of check box control properties, including dimension properties and some attribute properties, in addition to the general properties, and we'll show you how to better use this control from several scenarios that often use check box controls.
Scenario 1: Modifying the check box style
check boxes have five states: background Normal style, background down style, background disabled style, check identity style, check mark disabled style, each state can be defined by a picture. If you want to implement a general check box style, such as:
You can set the picture of five states individually and have achieved your desired effect if you want to implement the music on (off) style of the settings interface, such as:
You only need to set the background Normal style, background down style, background disable style, and set the other two states to not enable state. In addition, new resources can be added via the button control's right-click menu.
Scenario 2: The Default check box in the game is checked (not checked).
When you set a check box to be selected, the initial state of this check box in the game is the selected state. You can modify the check box selection by using the Properties panel or the right-click menu.
3. Picture controls
Add a picture that can be set to nine Gongge, nine Gongge is a kind of image that can be distorted after stretching, after certain processing, the technology of not distortion after stretching. For the usage of nine Gongge please refer to 4, nine use. docx
The picture control has the following characteristics relative to the sprite control:
The original size can be changed without distortion of the image.
The same resource can be used to achieve different end effects by setting the parameters of nine Gongge.
The system overhead is larger than the sprite control, and it is not recommended to overuse the picture control.
Usage Scenarios
Also the interface in the official example, can you imagine where the image controls are made up?
After you get the official sample, open the DIFFICULTSELECT.CSD file to see how we use the picture control, and perhaps inspire your project. The background is made from a picture of the size of 16x32. Below we show you how to use the picture control to make this background.
Scenario 1: How to use the picture control
After you add a picture control to the canvas, set its picture asset property to the resource shown in the Properties section of the property panel to show the control's current picture resource thumbnail, you can either double-click the thumbnail to modify the control's picture resource, or you can drag the picture asset onto the current style resource to replace it with the new resource. In addition, you can add new resources through the right-click menu of the nine Gongge picture controls. Then turn on the "nine Gongge" property, and modify the top and bottom left and right margin of the nine Gongge control respectively is 0,0,10,0, and then modify the control size is 70, 32, the definition of these margins will affect the effect of nine Gongra, and achieve the desired effect. For the principle and detailed description of the nine Gongge, refer to 4, nine use. docx
4. Text
Text is also one of the most commonly used controls in the game. Add a text that lets you set styles or properties such as font, font size, alignment, and so on.
Usage Scenarios
Text controls, such as the main interface, are used in many places in the example:
Scenario 1: Modifying text styles with different fonts
If you need a special font, click the Import Font button to import a TTF-formatted font that will be packaged together when you publish the game. When you modify the font of text, be aware that when you do not specify a font to use, the font used is the default font for the device you are running, and the font of the player device for the game you are making.
5.FNT fonts
You can implement various art fonts by setting the Fnt font file. Compared to art figures, FNT fonts have the following characteristics:
. Available resources, support all kinds of text, is a well-made fnt font, it is not difficult to find, the font contains Chinese, English, numbers and some special characters.
. Complex production requires the use of professional software for production.
Usage Scenarios
Scenario 1: Using FNT fonts
After you add a fnt to the canvas, you select the Fnt font control, and the Properties section of the property panel shows the current style resource for the control, and you can double-click to modify the properties by Fnt font, or you can drag the FNT resource onto the current style resource to replace it with the new resource. In addition, new resources can be added via the button control's right-click menu. To modify fnt font text, simply select the control, modify the Text property in the property area, or modify the text pop-up through menu-edit text or double-click.
When you enter missing characters in fnt in the input box, the missing characters are displayed as spaces.
6. Progress bar
The progress bar allows you to display the speed and completion of the processing task, and you can set the style of the progress bar.
Usage Scenarios
In the official example, the physical recovery function uses the progress bar control, as shown in the green bar
Scenario 1: Modifying a progress bar style
After you add a progress bar on the canvas, select the progress bar control, and in the Attributes section of the Properties panel, the current style resource for the progress bar control is displayed, you can double-click to modify the Resource graph of the progress bar control, or you can drag the picture asset onto the current style resource to replace it with the new resource. In addition, new resources can be added through the right-click menu of the progress bar control. As in the example, we set the following background for it:
Scenario 2: Setting the progress bar direction
Implementation of the blood bar (one left, one to the right), only need to set the progress bar of the property "type", set to the left to right, from right to left, by modifying the progress bar direction can be in the game to achieve the life value of wartime display.
7. Slide Bar
Sliders can be set to slide progress, slider style, etc., the user can move the sliding slider bar in the corresponding control to display the corresponding value
Usage Scenarios
Sliders are used to set certain coherence properties, such as setting the volume level in many programs, and in the official example, we also do a slide show in the Setup interface:
Scenario 1: Modifying the slider bar style
For example, to set the progress bar in, you need the following five resources, they are used to set the slider's background style, internal progress bar style, slider Normal style, slider style, slider disabled style, each state can be defined by the picture. In our example, the disabled state is not set.
After you add a slider bar to the canvas, select the slider control, and in the Properties section of the property panel, the current style resource for the slider control is displayed, and you can double-click to modify the properties of the slider control, or you can drag the picture asset onto the current style resource to replace it with the new resource.
In addition, new resources can be added through the right-click menu of the slider control.
8. Art figures
The effect of art figures can be achieved by a PNG image containing "./0123456789", with each character having a high image height and a width of 1/12 of the picture, through which digital art figures can be used to achieve artistic effects, which can be easily and effectively enrich the visual effects of the game. Compared to fnt fonts, art numbers have the following characteristics:
. Easy to make, fnt font making complex, and art numbers are simpler
. With less available resources, art figures only support ".", "/", "0-9 numbers"
Usage Scenarios
In our official example, the selection level here uses the art numbers
Scenario 1: Modifying art digital picture resources
After you add an art number to the canvas, select the art number control, and in the Attributes section of the Properties panel, the current picture resource thumbnail of the control is displayed, you can either double-click the thumbnail to modify the control's picture resource, or you can drag the picture asset onto the current style resource to replace it with the new resource. In addition, new resources can be added through the right-click menu of the art digital controls. Modify the button text by simply selecting the button, modifying the Text property in the property area, or by clicking "menu-Edit Text" or "double-click" To change the text pop-up window.
Special Instructions
When making art figures, a game art designer is required to provide a picture containing the ".", "/", "0-9 numbers", ensuring that the order is./0123456789, and that each individual number can be divided by 12 equal to the width of the image.
A typical art digital picture resource
Custom controls
The armature control supports the animation controls that are produced by importing the 1.x version of the Cocos Studio motion Editor. You can use the armature control to implement the ability to add animated content in Cocos Studio v2.x, and to control the current animation list and playback status. and preview the animation in the editor.
Usage scenarios:
Scenario 1: Import and export the file using the 1.x version of the animation.
You can import a prepared animated export file (Exportjson file) for the armature control:
. Drag files from the resources panel to the armature control's file properties, release the mouse to implement file import;
. In the Properties panel, click "Import File" button to select File import;
. Select the file import by right-clicking the armature control in the canvas and selecting "Set Armature file".
Scenario 2: Controlling the playback state of the animation:
You can set the current animation list for the armature control, and you can specify that the armature control loop to play the animation or specify whether the armature control plays automatically when the game is created.
(8) UI (Control)