>
>
> Would it be possible to run the callback when I init a "mouse" object? I
> feel like it should be possible but I can't seem to figure out how to
> reference or pointer the object being initialized from within it's own
> constructor. Similar to the below, replacing thisObject for something?
>
> type Mouse
> position
>
> function Mouse(window)
> position = (0.0,0.0)
> GLFW.SetCursorPosCallback(window, (x,y)->thisObject.position = (x,
> y))
>
> new(position)
> end
> end
>
>
>
> Sure, the key point is that `new(...)` returns the new instance. So in
your example it would be like
type Mouse
position
function Mouse(window)
position = (0.0,0.0)
self = new(position)
GLFW.SetCursorPosCallback(window, (x,y)->(self.position=(x,y);
nothing))
return self
end
end
I wouldn't use a Tuple to store the position though. Maybe Graphics.Vec2 is
more suitable.
- Alex.