浏览器不支持canvas
1.Click space to pause or begin game. 2.Enter the letter on the rockets to hit them. 3.Number of the hearts will add one together with the rockets after ten rockets hit. 4.Failed when the number of hearts equals zero. 5.Click anywhere to start game!
common.js中并未使用setTimeOut()或者setInterval()作为动画定时器,而是使用window.requestAnimationFrame,一种更为优化的方式实现动画效果。
requestAnimFrame的用法,先设置浏览器的兼容,并设置动画的帧率,这里设置为每1000/60ms执行一次回调函数
window.requestAnimFrame = (function() {
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function(callback) {
window.setTimeout(callback, 1000 / 60);
};
})();
复制
requestAnimFrame中的两个参数,callback为下次重画执行的函数,element为要重画的节点,即
requestAnimFrame(callback, element);
Substrate开发在基于UNIX的操作系统(如macOS或Linux)上是最容易的。
要在 macOS 或 Linux 上安装所需的软件包,请执行以下操作:
操作系统 | 安装命令 |
---|---|
Ubuntu 或 Debian | sudo apt update && sudo apt install -y git clang curl libssl-dev llvm libudev-dev |
Arch Linux | pacman -Syu --needed --noconfirm curl git clang |
fedora | sudo dnf update sudo dnf install clang curl git openssl-devel |
OpenSUSE | sudo zypper install clang curl git openssl-devel llvm-devel libudev-devel |
macOS | brew update && brew install openssl |
如果您使用的是 macOS 且未安装 Homebrew,请运行以下命令来安装 Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
安装完成后,运行 :brew install openssl
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。