添加绝对坐标

This commit is contained in:
Harvey Zack committed 2019-05-09 18:15:35 +08:00
1 parent c95d379064
commit 0335c678d5
3 files changed
+25 -3

No files matched your search

+13 -1
View File
@@ -5,11 +5,23 @@ export default function rectMix(art, player) {
},
});
['bottom', 'height', 'left', 'right', 'top', 'width', 'x', 'y'].forEach(key => {
['bottom', 'height', 'left', 'right', 'top', 'width'].forEach(key => {
Object.defineProperty(player, key, {
get: () => {
return player.rect[key];
},
});
});
Object.defineProperty(player, 'x', {
get: () => {
return player.left + window.pageXOffset;
},
});
Object.defineProperty(player, 'y', {
get: () => {
return player.top + window.pageYOffset;
},
});
}