User Tools

Site Tools


developer_center:developer_editor:online_gift_packs

Online Gift Packs

(12-minutes reading)

Guide

By reading the full text, you will master the online gift package based on the UI editor, which specifically covers the following points:

  1. UI real-time text refresh realized by looping triggers.
  2. Some skills in UI interface creation and trigger creation.
  3. Judgment of conditions when rewards are issued.
  4. Rewards issued after conditions are met.

Note: The content of the online gift package function can only be realized by using the UI editing function in the game. UI editing related tutorials:
* UI Editor
* UI Store

Effect Display

UI Making

First of all, we need to make the basic UI interface to complete the subsequent content.
Create the UI component content as shown in the picture below:
Make the main interface part of the online reward interface. Note that the “Online Duration” text box is an independent component created separately to facilitate subsequent trigger settings. And the “Receiving” needs to be a button component.

Trigger setting

Online Timing

Create a private timer variable “Online Time” to record the player's online time.

Then create a new trigger “Online Time”, set the event to “When any player enters the game”, and start the “Online Time” timer of the player who triggered the event.

After setting up the trigger to record the player's online time, we also need to know how long he is currently online when the player opens the interface.
So continue to create two new triggers “Duration Refresh 1” and “Duration Refresh 2”, and set the event of “Duration Refresh 1” to “Every second the game runs”, and set the action to “Run 'Duration Refresh 2' for all players” device“.

Then add a new action for the “Duration Refresh 2” trigger, and set the text content of the independent text element “Online Duration” mentioned in the previous steps to string concatenation.

It is not intuitive enough if the time duration is only displayed in seconds, so we also need to convert seconds to minutes.
In the String Concatenation, we add two more string concatenations with the purpose of changing the two text contents to “min” and “s”. The specific settings steps are as follows:

Then set the first “Value to String” space as shown in the figure below, divide the player's online time by 60 and round down to convert it to the player's online minutes.

It is also necessary to divide the online time of the player by 60 and then take the remainder as the content of the second “convert the value into a string”, which is the “Seconds” part of the online time.

After setting the triggers of the above steps, the effect of online duration timers can be realized.

Reward collection

Make related functions for players to receive rewards after meeting the conditions. First, create two triggers of “receive success” and “receive failure” to realize the two situations that may occur when the player presses the button.
Receive success: The first tier of rewards currently designed is for the player to be online for 5 minutes, which is 300 seconds. So set the “receive success” trigger as follows:

Event: “Any button on the current interface is released”.
Conditions: The button is the “Receive” button; the player's private timer “Online Time” is greater than or equal to 300.
Action: Make the player obtain the item type indicated by the UI icon, and then hide the claim button.

Receive failure: The condition is that the player's online time is less than 300, and the action “show the window text to the player”.

After the above setting, the function of issuing rewards according to the player's online time is completed.

If you want to set rewards for different stages, you only need to copy the original UI elements and arrange them, and then modify the prop images.


Next, copy the entire “reward claim” trigger group and rename it “reward claim 2”, and then modify the corresponding conditions and reward content issued.

If you need more levels of rewards when designing the interface, you only need to copy and modify the corresponding triggers and corresponding components.

developer_center/developer_editor/online_gift_packs.txt · Last modified: 2024/05/19 04:04 by don