mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
Update for the latest GopherJS (use *js.Object instead of js.Object)
This commit is contained in:
parent
246ac055bf
commit
bca600a093
@ -27,7 +27,7 @@ import (
|
||||
|
||||
func NewImageFromFile(path string, filter ebiten.Filter) (*ebiten.Image, image.Image, error) {
|
||||
var err error
|
||||
var content js.Object
|
||||
var content *js.Object
|
||||
ch := make(chan struct{})
|
||||
req := js.Global.Get("XMLHttpRequest").New()
|
||||
req.Call("open", "GET", path, true)
|
||||
|
@ -26,9 +26,9 @@ func withChannels(f func()) {
|
||||
|
||||
// Keep this so as not to be destroyed by GC.
|
||||
var (
|
||||
nodes = []js.Object{}
|
||||
dummies = []js.Object{} // Dummy source nodes for iOS.
|
||||
context js.Object
|
||||
nodes = []*js.Object{}
|
||||
dummies = []*js.Object{} // Dummy source nodes for iOS.
|
||||
context *js.Object
|
||||
)
|
||||
|
||||
const bufferSize = 1024
|
||||
@ -37,7 +37,7 @@ type audioProcessor struct {
|
||||
channel int
|
||||
}
|
||||
|
||||
func (a *audioProcessor) Process(e js.Object) {
|
||||
func (a *audioProcessor) Process(e *js.Object) {
|
||||
// Can't use 'go' here. Probably it may cause race conditions.
|
||||
b := e.Get("outputBuffer")
|
||||
l := b.Call("getChannelData", 0)
|
||||
|
@ -24,25 +24,25 @@ import (
|
||||
)
|
||||
|
||||
type Texture struct {
|
||||
js.Object
|
||||
*js.Object
|
||||
}
|
||||
|
||||
type Framebuffer struct {
|
||||
js.Object
|
||||
*js.Object
|
||||
}
|
||||
|
||||
var ZeroFramebuffer Framebuffer
|
||||
|
||||
type Shader struct {
|
||||
js.Object
|
||||
*js.Object
|
||||
}
|
||||
|
||||
type Program struct {
|
||||
js.Object
|
||||
*js.Object
|
||||
}
|
||||
|
||||
type Buffer struct {
|
||||
js.Object
|
||||
*js.Object
|
||||
}
|
||||
|
||||
// TODO: Remove this after the GopherJS bug was fixed (#159)
|
||||
@ -51,7 +51,7 @@ func (p Program) Equals(other Program) bool {
|
||||
}
|
||||
|
||||
type UniformLocation struct {
|
||||
js.Object
|
||||
*js.Object
|
||||
}
|
||||
|
||||
type AttribLocation int
|
||||
@ -192,7 +192,7 @@ func (c *Context) NewFramebuffer(t Texture) (Framebuffer, error) {
|
||||
return Framebuffer{f}, nil
|
||||
}
|
||||
|
||||
var lastBindedFramebuffer js.Object
|
||||
var lastBindedFramebuffer *js.Object
|
||||
|
||||
func (c *Context) SetViewport(f Framebuffer, width, height int) error {
|
||||
// TODO: Not sure if Flush is needed here.
|
||||
|
@ -65,7 +65,7 @@ func SetScreenScale(scale int) (bool, int) {
|
||||
return result, actualScale
|
||||
}
|
||||
|
||||
var canvas js.Object
|
||||
var canvas *js.Object
|
||||
|
||||
type userInterface struct{}
|
||||
|
||||
@ -161,55 +161,55 @@ func Init() {
|
||||
canvas.Get("style").Set("outline", "none")
|
||||
|
||||
// Keyboard
|
||||
canvas.Call("addEventListener", "keydown", func(e js.Object) {
|
||||
canvas.Call("addEventListener", "keydown", func(e *js.Object) {
|
||||
e.Call("preventDefault")
|
||||
code := e.Get("keyCode").Int()
|
||||
currentInput.KeyDown(code)
|
||||
})
|
||||
canvas.Call("addEventListener", "keyup", func(e js.Object) {
|
||||
canvas.Call("addEventListener", "keyup", func(e *js.Object) {
|
||||
e.Call("preventDefault")
|
||||
code := e.Get("keyCode").Int()
|
||||
currentInput.KeyUp(code)
|
||||
})
|
||||
|
||||
// Mouse
|
||||
canvas.Call("addEventListener", "mousedown", func(e js.Object) {
|
||||
canvas.Call("addEventListener", "mousedown", func(e *js.Object) {
|
||||
e.Call("preventDefault")
|
||||
button := e.Get("button").Int()
|
||||
currentInput.MouseDown(button)
|
||||
setMouseCursorFromEvent(e)
|
||||
})
|
||||
canvas.Call("addEventListener", "mouseup", func(e js.Object) {
|
||||
canvas.Call("addEventListener", "mouseup", func(e *js.Object) {
|
||||
e.Call("preventDefault")
|
||||
button := e.Get("button").Int()
|
||||
currentInput.MouseUp(button)
|
||||
setMouseCursorFromEvent(e)
|
||||
})
|
||||
canvas.Call("addEventListener", "mousemove", func(e js.Object) {
|
||||
canvas.Call("addEventListener", "mousemove", func(e *js.Object) {
|
||||
e.Call("preventDefault")
|
||||
setMouseCursorFromEvent(e)
|
||||
})
|
||||
canvas.Call("addEventListener", "contextmenu", func(e js.Object) {
|
||||
canvas.Call("addEventListener", "contextmenu", func(e *js.Object) {
|
||||
e.Call("preventDefault")
|
||||
})
|
||||
|
||||
// Touch (emulating mouse events)
|
||||
// TODO: Create indimendent touch functions
|
||||
canvas.Call("addEventListener", "touchstart", func(e js.Object) {
|
||||
canvas.Call("addEventListener", "touchstart", func(e *js.Object) {
|
||||
e.Call("preventDefault")
|
||||
currentInput.MouseDown(0)
|
||||
touches := e.Get("changedTouches")
|
||||
touch := touches.Index(0)
|
||||
setMouseCursorFromEvent(touch)
|
||||
})
|
||||
canvas.Call("addEventListener", "touchend", func(e js.Object) {
|
||||
canvas.Call("addEventListener", "touchend", func(e *js.Object) {
|
||||
e.Call("preventDefault")
|
||||
currentInput.MouseUp(0)
|
||||
touches := e.Get("changedTouches")
|
||||
touch := touches.Index(0)
|
||||
setMouseCursorFromEvent(touch)
|
||||
})
|
||||
canvas.Call("addEventListener", "touchmove", func(e js.Object) {
|
||||
canvas.Call("addEventListener", "touchmove", func(e *js.Object) {
|
||||
e.Call("preventDefault")
|
||||
touches := e.Get("changedTouches")
|
||||
touch := touches.Index(0)
|
||||
@ -217,12 +217,12 @@ func Init() {
|
||||
})
|
||||
|
||||
// Gamepad
|
||||
window.Call("addEventListener", "gamepadconnected", func(e js.Object) {
|
||||
window.Call("addEventListener", "gamepadconnected", func(e *js.Object) {
|
||||
// Do nothing.
|
||||
})
|
||||
}
|
||||
|
||||
func setMouseCursorFromEvent(e js.Object) {
|
||||
func setMouseCursorFromEvent(e *js.Object) {
|
||||
scale := canvas.Get("dataset").Get("ebitenScale").Int()
|
||||
rect := canvas.Call("getBoundingClientRect")
|
||||
x, y := e.Get("clientX").Int(), e.Get("clientY").Int()
|
||||
|
Loading…
Reference in New Issue
Block a user