luxeengine / alpha

alpha - deprecated 2015~2016. unrelated to the new engine! view the new engine here - https://luxeengine.com/
MIT License
565 stars 74 forks source link

Cursor invisibility? #389

Closed ghost closed 8 years ago

ghost commented 8 years ago

How I can do that? Luxe.screen.cursor hasn`t field visible.

ntrf commented 8 years ago

Luxe.snow.runtime.window_grab(true); to hide pointer and force all mouse-move events to be relative Luxe.snow.runtime.window_grab(true); to show it again

Note: You can open console (press ~ key) to show mouse if something goes wrong.

ghost commented 8 years ago

@ntrf Oh, thanks you again :+1:

ghost commented 8 years ago

@ntrf, but what if I want to make a custom cursor? How can i do this?

ntrf commented 8 years ago

No idea. In my game (flight simulator) i have a targeting crosshair following the invisible cursor every time it moves, but it's a 3d object in scene. Maybe you can do it with SDL api (https://github.com/snowkit/linc_sdl/tree/master/sdl). That option doen't work in my game beacuse i need it to be playable with gamepad.

ghost commented 8 years ago

@ntrf, Understood. I look at this later. Thx.

ruby0x1 commented 8 years ago

@CamperPR you can use the SDL api, but keep in mind that it is cpp target specific.

sdl.SDL.showCursor(false); sdl.SDL.showCursor(true);

For custom cursor you have to abide by the platform rules, and SDL let's you set some options but it may require a bit of effort, I haven't tried it but you basically have to take the pixels from an image asset and give them to the api as bytes data.

For web target, cursor visibility is added/removed to the css, which you can use the haxe js api's to access the game canvas by id and do anything needed from there.

ghost commented 8 years ago

I spent much time to find this:

#if web
js.Browser.document.getElementById("app").style.cursor = 'none';
#end

I want to cry...