examples/contextlost: Bug fix: Add 'js' build tag

Importing 'syscall/js' requires 'js' environment.
This commit is contained in:
Hajime Hoshi 2019-05-01 17:54:08 +09:00
parent 2aa79e0aa4
commit 80ae508d29

View File

@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// +build js
// +build example jsgo // +build example jsgo
package main package main
@ -75,7 +76,7 @@ func loseAndRestoreContext(context js.Value) {
} }
func update(screen *ebiten.Image) error { func update(screen *ebiten.Image) error {
if inpututil.IsKeyJustPressed(ebiten.KeySpace) && js.Global() != js.Null() { if inpututil.IsKeyJustPressed(ebiten.KeySpace) {
doc := js.Global().Get("document") doc := js.Global().Get("document")
canvas := doc.Call("getElementsByTagName", "canvas").Index(0) canvas := doc.Call("getElementsByTagName", "canvas").Index(0)
context := canvas.Call("getContext", "webgl") context := canvas.Call("getContext", "webgl")