mobile: Enable to compile in non-mobile environments

This was necessary to show API documents on godoc.org and
pkg.go.dev.
This commit is contained in:
Hajime Hoshi 2019-11-18 02:18:10 +09:00
parent c6cc298e0d
commit d7a9193e52
3 changed files with 48 additions and 4 deletions

25
mobile/impl_mobile.go Normal file
View File

@ -0,0 +1,25 @@
// Copyright 2019 The Ebiten Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// +build android ios
package mobile
import (
"github.com/hajimehoshi/ebiten/mobile/ebitenmobileview"
)
func setGame(game Game) {
ebitenmobileview.SetGame(game)
}

22
mobile/impl_notmobile.go Normal file
View File

@ -0,0 +1,22 @@
// Copyright 2019 The Ebiten Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// +build !android
// +build !ios
package mobile
func setGame(game Game) {
panic("mobile: setGame is not implemented in this environment")
}

View File

@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
// +build android ios
// Package mobile provides functions for mobile platforms (Android and iOS).
//
// This package is used when you use `ebitenmobile bind`.
@ -23,7 +21,6 @@ package mobile
import (
"github.com/hajimehoshi/ebiten"
"github.com/hajimehoshi/ebiten/mobile/ebitenmobileview"
)
// Game defines necessary functions for a mobile game.
@ -49,5 +46,5 @@ type Game interface {
//
// SetGame can be called anytime. Until SetGame is called, the game does not start.
func SetGame(game Game) {
ebitenmobileview.SetGame(game)
setGame(game)
}