HTML5 game Kiwijs (3)-Key, animation __HTML5

Source: Internet
Author: User
Tags addchild

Create left and Right buttons to control NPC walking and release skill animation.

First, prepare a NPC Lianbo animation map and a skill Lianbo chart



Creating NPC animations in Kiwi.js is accomplished by means of the add (name cells speed [Loop=false] animationmanager [Play=false]) method of the

Create a background
            this.bgsprite = new Kiwi.GameObjects.StaticImage (this, this.textures.background, 1000,);
            this.bgsprite.x = 0;
            this.bgsprite.y = 0;
            This.addchild (this.bgsprite);
            Create game NPC
            This.snakesprite = new Kiwi.GameObjects.Sprite (this, this.textures.snake, 117);
            Create the action, make the display frame, frame length, etc.

            this.snakeSprite.animation.add ("Idle", [0,1], 0.3, true, true);
            This.snakeSprite.animation.add ("Walking", [0,1,2,3,4,5,6], 0.2, true, false);
            This.snakeSprite.animation.add ("Spawn", [1,2], 0.2, false, false);
            this.snakesprite.x = m;
            This.snakesprite.y = 370;
            This.snakeSprite.speed = 2;
            This.addchild (This.snakesprite);

The complete code

<! DOCTYPE html> Effect chart




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.