zoukankan
html css js c++ java
Javascript, How to make a Dress Up Game (Drag and Drop)
<
style
>
<!--
.dragme
{position:relative;}
-->
</
style
>
<
script language
=
"
JavaScript1.2
"
>
<!--
var
ie
=
document.all;
var
nn6
=
document.getElementById
&&!
document.all;
var
isdrag
=
false
;
var
x,y;
var
dobj;
function
movemouse(e)
{
if
(isdrag)
{
dobj.style.left
=
nn6
?
tx
+
e.clientX
-
x : tx
+
event.clientX
-
x;
dobj.style.top
=
nn6
?
ty
+
e.clientY
-
y : ty
+
event.clientY
-
y;
return
false
;
}
}
function
selectmouse(e)
{
var
fobj
=
nn6
?
e.target : event.srcElement;
var
topelement
=
nn6
?
"
HTML
"
:
"
BODY
"
;
while
(fobj.tagName
!=
topelement
&&
fobj.className
!=
"
dragme
"
)
{
fobj
=
nn6
?
fobj.parentNode : fobj.parentElement;
}
if
(fobj.className
==
"
dragme
"
)
{
isdrag
=
true
;
dobj
=
fobj;
tx
=
parseInt(dobj.style.left
+
0
);
ty
=
parseInt(dobj.style.top
+
0
);
x
=
nn6
?
e.clientX : event.clientX;
y
=
nn6
?
e.clientY : event.clientY;
document.onmousemove
=
movemouse;
return
false
;
}
}
document.onmousedown
=
selectmouse;
document.onmouseup
=
new
Function(
"
isdrag=false
"
);
//
-->
</
script
>
<
img src
=
"
ttt.jpg
"
class
=
"
dragme
"
>
JSON(
http://www.json.org/json-zh.html
)
<
script
>
var
myJSONObject
=
{
"
bindings
"
:
[
{
"
ircEvent
"
:
"
PRIVMSG
"
,
"
method
"
:
"
newURI
"
,
"
regex
"
:
"
^http://.*
"
}
,
{
"
ircEvent
"
:
"
PRIVMSG
"
,
"
method
"
:
"
deleteURI
"
,
"
regex
"
:
"
^delete.*
"
}
,
{
"
ircEvent
"
:
"
PRIVMSG
"
,
"
method
"
:
"
randomURI
"
,
"
regex
"
:
"
^random.*
"
}
]
}
;
alert(myJSONObject.bindings[
0
].method);
//
"newURI"
</
script
>
查看全文
相关阅读:
BZOJ 3924: [Zjoi2015]幻想乡战略游戏
codevs 4244 平衡树练习
BZOJ 2002: [Hnoi2010]Bounce 弹飞绵羊
BZOJ 2038: [2009国家集训队]小Z的袜子
luogu P3709 大爷的字符串题
BZOJ 2120: 数颜色
luogu P2056 采花
luogu P2709 小B的询问
BZOJ 1878: [SDOI2009]HH的项链
Codeforces 221d D. Little Elephant and Array
原文地址:https://www.cnblogs.com/snowball/p/562873.html
最新文章
人事面试题总结
C#种将String类型转换成int型
相对位置和绝对位置
cocos2d-x入门学习--准备篇
如何显示电脑文件的后缀
failed to initialize unity graphics 错误解决方法(win7 unity4.x)
window 7喇叭有红叉,耳机扬声器已拔出驱动无法修复
window7 更改电脑黑屏时间
轻松学C#----第二篇笔记
轻松学C#----第一篇笔记
热门文章
HDU 1022 Train Problem I
Moving tables
N
L
K
Monthly Expense POJ 二分
POJ River Hopscotch 二分搜索
Aggressive Cows 二分
4 Values whose Sum is 0 二分
U
Copyright © 2011-2022 走看看