Game Making: Task event handling solutions for games

Source: Internet
Author: User
Solve

Effect:

Click here to download the source file

In the game, especially RPG games, often have a lot of tasks, the following is my task of the game solution, provide everyone to share:

The first step: first write a task of class task.as

Class Task {
Define the name of the event, progress, description
var sjname, SJJD, SJMS;
function Task (N, J, M) {
Sjname = N;
SJJD = J;
SJMS = M;
}
Display individual Task Information
function Sjinfo (a) {
if (a = = 1) {
return SJMS;
}
return sjname;
}
Complete the task
function Sjfinish () {
if (sjjd==0) {
SJJD = 1;
} else {
Trace (sjname+ "task, completed or not triggered");
}
}
Trigger Task
function Sjopen () {
if (sjjd==-1)
{
SJJD = 0;}
else{
Trace (sjname+ "task, has been triggered or completed");
}
}
Step Two: Create a new flash test under the TASK.AS directory. FLA, declare all the tasks of the game in the first frame

Define event (name, progress, description)
var sj1:task = new Task ("Help Uncle Wang",-1, "to the nearby Ox Mountain to help uncle Wang see his grandson");
var sj2:task = new Task ("Help the future to find a daughter-in-law",-1, "to Chongqing to find help to learn daughter-in-law");
var sj3:task = new Task ("Help Uncle Li",-1, "Messenger to Aunt Zhang in next village)";
var sj4:task = new Task ("Help Zhao Outside", 1, "to the nearby Danxia Ridge to help Zhao collect herbs");
var sj5:task = new Task ("Help the Blacksmith", 0, "The blacksmith's daughter was abducted by the mountain thieves, in the black wind hole inside the area to find clues");
var alltask = new Array (Sj1, Sj2, Sj3, Sj4, Sj5);
Show List of events
function Showshijian () {
_root. Info = "<font color=\" #000000 \ "> System message </font> <br>========================<br>";
for (var i:number = 0; i<_root. Alltask.length; i++) {
if (_root. Alltask[i]. SJJD = = 0) {
_root. Info + + "<br>" + (i+1) + "," +_root. Alltask[i]. sjms+ "<font color=\" #FFF000 \ ">[]</font><br>----------------";
}
if (_root. Alltask[i]. SJJD = = 1) {
_root. Info + + "<br>" + (i+1) + "," +_root. Alltask[i]. sjms+ "<font color=\" #FF0000 \ ">[has been completed]</font><br>----------------";
}
if (_root. Alltask[i]. SJJD = =-1) {
_root. Info + + "<br>" + (i+1) + "," +_root. Alltask[i]. sjms+ "<font color=\" #999999 \ ">[did not trigger]</font><br>----------------";
}
}
Step three: Put the following components above the first frame
1. Draw a dynamic text, the property is set as follows: Multiline display, allow HTML, variable info
2, drag into 1 flash button components, the properties are as follows: The parameter label is: Get the task list, plus the following as

On (click)
{
_root. Showshijian ();
}
3, drag into 1 flash button components, the properties are as follows: The parameter label is: Activate Event 1, plus the following as

On (click)
{
_root. Sj1.sjopen ();
_root. Showshijian ();
}
4, drag into 1 flash button components, the properties are as follows: The parameter label is: To complete the task 1, plus the following as
On (click)
{
_root. Sj1.sjfinish ();
_root. Showshijian ();
}
It's done here.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.