Html5 uses canvas to implement simple super Mary Animation

Source: Internet
Author: User

Comments: Recently I have been studying html5, which involves a key element canvas-canvas. After searching and researching, I have finally implemented a simple animation for super Mary. I would like to share with you the following, I hope to help beginners. I recently studied html5, which involves the canvas-canvas, a key element. I downloaded some game source code on the Internet. Although I can understand it, however, it is still difficult to extract a function separately. As a result, I searched for some examples on the Internet to implement a simple animation of super Mary.

The main drawImage () functions involved in the Design

(1) drawImage (image, x, y) is the most basic operation method. It refers to plotting the entire image object you want to operate on the specified axis, the upper left corner is the (0, 0) origin to calculate the position you want it to depict.
(2) drawImage (image, x, y, width, height) scales the image object you need to operate and then depicts it on the canvas, width and height are the sizes after the image is depicted.
(3) drawImage (image, sourceX, sourceY, sourceWidth, sourceHeight, destX, destY, destWidth, and destHeight) is the most complex method, but it is also quite useful. It indicates that in the image object you want to operate, select the position (sourceX, sourceY) in the upper left corner of the image object you want to locate, and then extract the width and height (sourceWidth, sourceHeight) you want ), the captured image is depicted within the position (destX, destY) and range (destWidth, destHeight) of the canvas.

1. First, I searched for a picture of super Mary's consistent walking behavior on the Internet (for example)
 
2.create an HTML 5 file named mario.html, define the canvas Element, start the animation, and stop the animation.
 
3. Related js Functions

 

Related Article

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.