


js game character running up, down, left and right effect code sharing_javascript skills
The example in this article describes the effect of js game characters running up, down, left and right. Share it with everyone for your reference. The details are as follows:
The js game character running up, down, left and right effect is a click button grid layout avatar picture animation switching special effect produced by jquery ui. Isn’t it interesting that you control the game character and control everything? Friends who are interested can learn about it
Operation rendering: -------------------View the effect Download the source code---------- --------
Tips: If the browser does not work properly, you can try switching the browsing mode.
The jQuery implementation of the hot air balloon animation background login box code shared with you is as follows
<!DOCTYPE html> <html> <head> <title>js游戏人物上下左右跑步效果 </title> <meta charset="utf-8"/> <style type="text/css"> table { position: absolute; top: 100px; right: 100px; width: 150px; height: 150px; } input { width: 40px; height: 30px; background: orange; color: white; font-weight: bold; border: none; border-radius: 5px; } img { position: absolute; top: 300px; left: 500px; } </style> </head> <body> <img id="im" src="images/down-0.png" /> <table> <tr> <td><input id="leftUp" type="button" value="左上" /></td> <td><input id="goUp" type="button" value="向上" /></td> <td><input id="rightUp" type="button" value="右上" /></td> </tr> <tr> <td><input id="goLeft" type="button" value="左" /></td> <td><input id="stop" type="button" value="停止" /></td> <td><input id="goRight" type="button" value="右" /></td> </tr> <tr> <td><input id="leftDown" type="button" value="左下" /></td> <td><input id="goDown" type="button" value="向下" /></td> <td><input id="rightDown" type="button" value="右下" /></td> </tr> </table> <script type="text/javascript"> var i = 0, clc = null, flage; var images = document.getElementById('im'); var oGoUp = document.getElementById('goUp'); var oGoDown = document.getElementById('goDown'); var oGoLeft = document.getElementById('goLeft'); var oGoRight = document.getElementById('goRight'); var oLeftUp = document.getElementById('leftUp'); var oLeftDown = document.getElementById('leftDown'); var oRightUp = document.getElementById('rightUp'); var oRightDown = document.getElementById('rightDown'); var oStop = document.getElementById('stop'); images.style.top = '300px'; images.style.left = '500px'; //停止 oStop.onclick = function(){ switch(flage){ case 1: images.src = 'images/up-0.png';break; case 2: images.src = 'images/down-0.png';break; case 3: images.src = 'images/left-0.png';break; case 4: images.src = 'images/right-0.png';break; case 5: images.src = 'images/rightUp-0.png';break; case 6: images.src = 'images/rd-0.png';break; case 7: images.src = 'images/ld-0.png';break; case 8: images.src = 'images/lu-0.png';break; } clearInterval(clc); } //向上 oGoUp.onclick = function(){ i = 0; clearInterval(clc); clc = setInterval("goUp(i++);", 100); } function goUp(){ i = i % 4; var name ="images/up-" + i + "." + "png"; images.src = name; images.style.top = parseInt(images.style.top) - 10 + 'px'; flage = 1; } //向下 oGoDown.onclick = function(){ i = 0; clearInterval(clc); clc = setInterval("goDown(i++);", 100); } function goDown(){ i = i % 4; var name ="images/down-" + i + "." + "png"; images.src = name; images.style.top = parseInt(images.style.top) + 10 + 'px'; flage = 2; } //向左 oGoLeft.onclick = function(){ i = 0; clearInterval(clc); clc = setInterval("goLeft(i++);", 100); } function goLeft(){ i = i % 4; var name ="images/left-" + i + "." + "png"; images.src = name; images.style.left = parseInt(images.style.left) - 10 + 'px'; flage = 3; } //向右 oGoRight.onclick = function(){ i = 0; clearInterval(clc); clc = setInterval("goRight(i++);", 100); } function goRight(){ i = i % 4; var name ="images/right-" + i + "." + "png"; images.src = name; images.style.left = parseInt(images.style.left) + 10 + 'px'; flage = 4; } //向右上 oRightUp.onclick = function(){ i = 0; clearInterval(clc); clc = setInterval("goRightUp(i++);", 100); } function goRightUp(){ i = i % 4; var name ="images/rightUp-" + i + "." + "png"; images.src = name; images.style.left = parseInt(images.style.left) + 10 + 'px'; images.style.top = parseInt(images.style.top) - 10 + 'px'; flage = 5; } //向右下 oRightDown.onclick = function(){ i = 0; clearInterval(clc); clc = setInterval("goRightDown(i++);", 100); } function goRightDown(){ i = i % 4; var name ="images/rd-" + i + "." + "png"; images.src = name; images.style.left = parseInt(images.style.left) + 10 + 'px'; images.style.top = parseInt(images.style.top) + 10 + 'px'; flage = 6; } //向左下 oLeftDown.onclick = function(){ i = 0; clearInterval(clc); clc = setInterval("goLeftDown(i++);", 100); } function goLeftDown(){ i = i % 4; var name ="images/ld-" + i + "." + "png"; images.src = name; images.style.left = parseInt(images.style.left) - 10 + 'px'; images.style.top = parseInt(images.style.top) + 10 + 'px'; flage = 7; } //向左上 oLeftUp.onclick = function(){ i = 0; clearInterval(clc); clc = setInterval("goLeftUp(i++);", 100); } function goLeftUp(){ i = i % 4; var name ="images/lu-" + i + "." + "png"; images.src = name; images.style.left = parseInt(images.style.left) - 10 + 'px'; images.style.top = parseInt(images.style.top) - 10 + 'px'; flage = 8; } </script> <div style="text-align:center;clear:both"> </div> </body> </html>
The above is the js game character running up, down, left, and right effect code shared with you. I hope you like it.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Frequently Asked Questions and Solutions for Front-end Thermal Paper Ticket Printing In Front-end Development, Ticket Printing is a common requirement. However, many developers are implementing...

There is no absolute salary for Python and JavaScript developers, depending on skills and industry needs. 1. Python may be paid more in data science and machine learning. 2. JavaScript has great demand in front-end and full-stack development, and its salary is also considerable. 3. Influencing factors include experience, geographical location, company size and specific skills.

How to merge array elements with the same ID into one object in JavaScript? When processing data, we often encounter the need to have the same ID...

JavaScript is the cornerstone of modern web development, and its main functions include event-driven programming, dynamic content generation and asynchronous programming. 1) Event-driven programming allows web pages to change dynamically according to user operations. 2) Dynamic content generation allows page content to be adjusted according to conditions. 3) Asynchronous programming ensures that the user interface is not blocked. JavaScript is widely used in web interaction, single-page application and server-side development, greatly improving the flexibility of user experience and cross-platform development.

In-depth discussion of the root causes of the difference in console.log output. This article will analyze the differences in the output results of console.log function in a piece of code and explain the reasons behind it. �...

Discussion on the realization of parallax scrolling and element animation effects in this article will explore how to achieve similar to Shiseido official website (https://www.shiseido.co.jp/sb/wonderland/)...

Once you have mastered the entry-level TypeScript tutorial, you should be able to write your own code in an IDE that supports TypeScript and compile it into JavaScript. This tutorial will dive into various data types in TypeScript. JavaScript has seven data types: Null, Undefined, Boolean, Number, String, Symbol (introduced by ES6) and Object. TypeScript defines more types on this basis, and this tutorial will cover all of them in detail. Null data type Like JavaScript, null in TypeScript

JavaScript can be run in PowerPoint, and can be implemented by calling external JavaScript files or embedding HTML files through VBA. 1. To use VBA to call JavaScript files, you need to enable macros and have VBA programming knowledge. 2. Embed HTML files containing JavaScript, which are simple and easy to use but are subject to security restrictions. Advantages include extended functions and flexibility, while disadvantages involve security, compatibility and complexity. In practice, attention should be paid to security, compatibility, performance and user experience.
