Motio:简单但功能强大的的 jQuery 精灵动画插件

您可能感兴趣的相关文章

 

  Motio 是一个简单但功能强大的的实现精灵动画和平移的 jQuery 插件。Motio 要求元素在动画容器内,在 CSS 背景图像中实现动画效果。在基于精灵的动画中,容器应该和一帧精灵的尺寸一样。例如,如果你有10帧水平方向的精灵,总共 1000 x 100 像素,那么动画容器应为 100×100 像素大。

 

 

实现一个简单的游戏

  Motio 原本设计是用来实现简单的精灵动画和平移效果的,不过也可以综合起来制作一款简单的游戏。

  操作:←左移 →右移 Space跳跃 B踢

 

 

 

  HTML 代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
<div id="game">
<div class="char">
<div class="stand"></div>
<div class="stand_left"></div>
<div class="run"></div>
<div class="run_left"></div>
<div class="jump"></div>
<div class="jump_left"></div>
<div class="kick"></div>
<div class="kick_left"></div>
</div>
<div class="overlay"></div>
</div>

  CSS 代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#game {
position: relative;
clear: both;
margin: 10px 0;
width: 100%;
height: 240px;
background: url('../img/minigame_bg.png') no-repeat center 0;
}
#game div {
position: absolute;
}
#game .char {
width: 120px;
height: 150px;
left: 410px;
bottom: 0;
}
#game .char div {
width: 100%;
height: 100%;
background: url('../img/sailormars.gif') no-repeat left top;
}
#game .char .stand {
background-position: 0 0;
}
#game .char .stand_left {
background-position: 0 -150px;
}
#game .char .run {
background-position: 0 -300px;
}
#game .char .run_left {
background-position: 0 -450px;
}
#game .char .jump {
background-position: 0 -600px;
}
#game .char .jump_left {
background-position: 0 -750px;
}
#game .char .kick {
background-position: 0 -900px;
}
#game .char .kick_left {
background-position: 0 -1050px;
}
#game .overlay {
width: 100%;
height: 100%;
left: 0;
top: 0;
z-index: 2;
background: url('../img/minigame_bg.png') no-repeat center -240px;
}

  JavaScript 代码如下:

 

Github     官方主页     猛击下载

  GitHub 被墙,需要配置 hosts:

1
2
3
4
207.97.227.239 github.com
207.97.227.252 nodeload.github.com
207.97.227.243 raw.github.com
204.232.175.78 documentcloud.github.com

您可能感兴趣的相关文章

 

本文链接:Motio:简单但功能强大的的 jQuery 精灵动画插件

编译来源:梦想天空 ◆ 关注前端开发技术 ◆ 分享网页设计资源

posted @   梦想天空(山边小溪)  阅读(6808)  评论(28编辑  收藏  举报
编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· SQL Server 2025 AI相关能力初探
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
历史上的今天:
2011-01-21 推荐10个非常有用的jQuery图片插件
点击右上角即可分享
微信分享提示