HTML5 2D Platform Game Development--the capacity-building skill of character action

Source: Internet
Author: User

In many action games, the player controls the role can cast a more powerful than the ordinary attack of the power technology, the general operation is to hold the attack key for a period of time and then release, the specific effect like the following picture:

To do this, first record the time the key is pressed and the initial is 0:

this. sabrechargetime = 0;

The next step is the time required to cast the skill, releasing the key after this time, and then casting the skill, otherwise invalid:

this. Max_sabre_charge_time = 150;

The code structure is as follows:

if(key[74]) {//Attack     This. Updatesabrecharge ();//Storage Capacity}Else {     This. Releasepowerslash ();//cast Attack}functionUpdatesabrecharge () { This. sabrechargetime++;}functionReleasepowerslash (callback) {if( This. sabrechargetime > This. Max_sabre_charge_time) { This. State =State .        Power_slash;  This. Play (); Callback&&callback (); }     This. Resetsabrecharge ();//Reset Counter}functionResetsabrecharge () { This. Sabrechargetime = 0; } 

You can trigger the charge by holding down the attack key at each stage of the character action.

Update Log

2017/04/09 Update role Jumps

2017/04/21 Update role Sprint

2017/05/01 Update role State machine

2017/05/16 Update character attack animations

2017/05/22 Update character mobile attack animation

2017/05/24 Update character jump attack animation

2017/06/04 Update Map Drawing

2017/06/22 update camera, long-distance sprint

2017/07/01 Update Command Technology

2017/07/06 update of the storage Force technology

HTML5 2D Platform Game Development--the capacity-building skill of character action

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.