Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
黛琳ghz
2048
提交
cf01ca7e
2048
项目概览
黛琳ghz
/
2048
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
2048
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
cf01ca7e
编写于
3月 23, 2014
作者:
G
Gabriele Cirulli
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
manually apply #81
上级
2f912471
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
85 addition
and
3 deletion
+85
-3
index.html
index.html
+2
-0
js/bind_polyfill.js
js/bind_polyfill.js
+9
-0
js/classlist_polyfill.js
js/classlist_polyfill.js
+71
-0
js/game_manager.js
js/game_manager.js
+2
-2
js/html_actuator.js
js/html_actuator.js
+1
-1
未找到文件。
index.html
浏览文件 @
cf01ca7e
...
@@ -82,6 +82,8 @@
...
@@ -82,6 +82,8 @@
</p>
</p>
</div>
</div>
<script
src=
"js/bind_polyfill.js"
></script>
<script
src=
"js/classlist_polyfill.js"
></script>
<script
src=
"js/animframe_polyfill.js"
></script>
<script
src=
"js/animframe_polyfill.js"
></script>
<script
src=
"js/keyboard_input_manager.js"
></script>
<script
src=
"js/keyboard_input_manager.js"
></script>
<script
src=
"js/html_actuator.js"
></script>
<script
src=
"js/html_actuator.js"
></script>
...
...
js/bind_polyfill.js
0 → 100644
浏览文件 @
cf01ca7e
Function
.
prototype
.
bind
=
Function
.
prototype
.
bind
||
function
(
target
)
{
var
self
=
this
;
return
function
(
args
)
{
if
(
!
(
args
instanceof
Array
))
{
args
=
[
args
];
}
self
.
apply
(
target
,
args
);
};
};
js/classlist_polyfill.js
0 → 100644
浏览文件 @
cf01ca7e
(
function
()
{
if
(
typeof
window
.
Element
===
"
undefined
"
||
"
classList
"
in
document
.
documentElement
)
{
return
;
}
var
prototype
=
Array
.
prototype
,
push
=
prototype
.
push
,
splice
=
prototype
.
splice
,
join
=
prototype
.
join
;
function
DOMTokenList
(
el
)
{
this
.
el
=
el
;
// The className needs to be trimmed and split on whitespace
// to retrieve a list of classes.
var
classes
=
el
.
className
.
replace
(
/^
\s
+|
\s
+$/g
,
''
).
split
(
/
\s
+/
);
for
(
var
i
=
0
;
i
<
classes
.
length
;
i
++
)
{
push
.
call
(
this
,
classes
[
i
]);
}
}
DOMTokenList
.
prototype
=
{
add
:
function
(
token
)
{
if
(
this
.
contains
(
token
))
return
;
push
.
call
(
this
,
token
);
this
.
el
.
className
=
this
.
toString
();
},
contains
:
function
(
token
)
{
return
this
.
el
.
className
.
indexOf
(
token
)
!=
-
1
;
},
item
:
function
(
index
)
{
return
this
[
index
]
||
null
;
},
remove
:
function
(
token
)
{
if
(
!
this
.
contains
(
token
))
return
;
for
(
var
i
=
0
;
i
<
this
.
length
;
i
++
)
{
if
(
this
[
i
]
==
token
)
break
;
}
splice
.
call
(
this
,
i
,
1
);
this
.
el
.
className
=
this
.
toString
();
},
toString
:
function
()
{
return
join
.
call
(
this
,
'
'
);
},
toggle
:
function
(
token
)
{
if
(
!
this
.
contains
(
token
))
{
this
.
add
(
token
);
}
else
{
this
.
remove
(
token
);
}
return
this
.
contains
(
token
);
}
};
window
.
DOMTokenList
=
DOMTokenList
;
function
defineElementGetter
(
obj
,
prop
,
getter
)
{
if
(
Object
.
defineProperty
)
{
Object
.
defineProperty
(
obj
,
prop
,
{
get
:
getter
});
}
else
{
obj
.
__defineGetter__
(
prop
,
getter
);
}
}
defineElementGetter
(
HTMLElement
.
prototype
,
'
classList
'
,
function
()
{
return
new
DOMTokenList
(
this
);
});
})();
js/game_manager.js
浏览文件 @
cf01ca7e
...
@@ -16,14 +16,14 @@ function GameManager(size, InputManager, Actuator, StorageManager) {
...
@@ -16,14 +16,14 @@ function GameManager(size, InputManager, Actuator, StorageManager) {
// Restart the game
// Restart the game
GameManager
.
prototype
.
restart
=
function
()
{
GameManager
.
prototype
.
restart
=
function
()
{
this
.
storageManager
.
clearGameState
();
this
.
storageManager
.
clearGameState
();
this
.
actuator
.
continue
();
// Clear the game won/lost message
this
.
actuator
.
continue
Game
();
// Clear the game won/lost message
this
.
setup
();
this
.
setup
();
};
};
// Keep playing after winning (allows going over 2048)
// Keep playing after winning (allows going over 2048)
GameManager
.
prototype
.
keepPlaying
=
function
()
{
GameManager
.
prototype
.
keepPlaying
=
function
()
{
this
.
keepPlaying
=
true
;
this
.
keepPlaying
=
true
;
this
.
actuator
.
continue
();
// Clear the game won/lost message
this
.
actuator
.
continue
Game
();
// Clear the game won/lost message
};
};
// Return true if the game is lost, or has won and the user hasn't kept playing
// Return true if the game is lost, or has won and the user hasn't kept playing
...
...
js/html_actuator.js
浏览文件 @
cf01ca7e
...
@@ -36,7 +36,7 @@ HTMLActuator.prototype.actuate = function (grid, metadata) {
...
@@ -36,7 +36,7 @@ HTMLActuator.prototype.actuate = function (grid, metadata) {
};
};
// Continues the game (both restart and keep playing)
// Continues the game (both restart and keep playing)
HTMLActuator
.
prototype
.
continue
=
function
()
{
HTMLActuator
.
prototype
.
continue
Game
=
function
()
{
this
.
clearMessage
();
this
.
clearMessage
();
};
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录