You are not logged in.
move "cursor_xpos()" "cursor_ypos()"
This Object-related functions will greatly help in the preparation of a cursor in the game, as an example to select something.
Example
object "Cursor"
{
category "cursor"
state "main"
{
set_animation "SD_CURSOR" 0
move "cursor_xpos()" "cursor_ypos()"
}
}
Offline
not really, you can still make your own cursor object and have it read xpos() and ypos(), and save the last known position in $_cursorx and $_cursory, for example.
xpos and ypos are the X and Y positions of the object, $_cursorx and $_cursory would be two global variables where you would save the last xpos() and ypos(), like this:
let "$_cursorx = xpos()"
let "$_cursory = ypos()"
and in this case I chose a global ($_*) instead of a local ($*) because you may want to read the cursor position from any other object, and as long as the cursor has saved its position at least once, any object can get that last position. If it returns 0 on both, it may mean that the cursor never moved, or that it was really at 0, 0 the last time it saved the position. So to test your object i suggest you create it at any other place, like 160, 120, for example. that would be the center of the screen.
Last edited by KZR (2012-10-10 19:17:04)
https://discord.gg/w8JqM7m ---> Open Surge's Discord server
Offline
not really, you can still make your own cursor object and have it read xpos() and ypos(), and save the last known position in $_cursorx and $_cursory, for example.
xpos and ypos are the X and Y positions of the object, $_cursorx and $_cursory would be two global variables where you would save the last xpos() and ypos(), like this:
let "$_cursorx = xpos()" let "$_cursory = ypos()"
and in this case I chose a global ($_*) instead of a local ($*) because you may want to read the cursor position from any other object, and as long as the cursor has saved its position at least once, any object can get that last position. If it returns 0 on both, it may mean that the cursor never moved, or that it was really at 0, 0 the last time it saved the position. So to test your object i suggest you create it at any other place, like 160, 120, for example. that would be the center of the screen.
ok, thanks
Offline
It's not working. He is giving bugs to go to the bottom right corner. What do I do?
Offline
can you post your code?
Offline
can you post your code?
I had put so:
object ".cursor_sprite"
{
always_active
state "main"
{
set_animation SD_ARROW 0
set_zindex infinity()
set_absolute_position $_cursorx $_cursory
}
}
object ".cursor_arrow"
{
always_active
detach_from_camera
state "main"
{
hide
set_animation SD_ARROW 0
set_absolute_position 160 120
create_child ".cursor_sprite"
change_state "input"
}
state "input"
{
let "$_cursorx = xpos()"
let "$_cursory = ypos()"
move "$_cursorx" "$_cursory"
}
}
Offline
What is it you're intending to do with this cursor, exactly? Also, why did you separate your animation from your object when it is really a simple matter of getting rid of the hide in the original object and moving your zindex into main of the actual object to have the same effect?
If I knew then what I know now I'd tell you that the story's true. Cause whatever you do, it comes back to you. -Slaughter, Burning Bridges
Offline
It's not working. He is giving bugs to go to the bottom right corner
indeed:
let "$_cursorx = xpos()"
let "$_cursory = ypos()"
move "$_cursorx" "$_cursory"
this won't work as intended.
take a look once again at the move command in the api reference.
Offline
I can definitely see benefits of having the cursor available for GUI and such things. This will come handy when the options screen gets their final touches.
Offline
MatheusRRR wrote:It's not working. He is giving bugs to go to the bottom right corner
indeed:
let "$_cursorx = xpos()" let "$_cursory = ypos()" move "$_cursorx" "$_cursory"
this won't work as intended.
take a look once again at the move command in the api reference.
alexandre what i can use to get a cursor?
Offline
how do you want to control such a cursor?
keyboard? mouse?
Offline
how do you want to control such a cursor?
keyboard? mouse?
Mouse
Offline
Just running a quick search against the current API it is currently impossible to read mouse input inside the level. I know for a fact it can be done in the editor, but in the main level it cannot. Anyway, perhaps your petition for mouse input should include the following:
What is it that having mouse input in levels would accomplish that would make things easier for you, and where in Open Surge would this be used?
Can you name some places where this would greatly enhance the gameplay of both hacks and the main engine game?
Can you say how you wish for this to be implemented? Do you want it to work similar to the way keyboard input currently works, namely that we have a listener that sends out signals when a key is pressed? Do we need to be able to sense clicks, and would the ability to sense clicks make the object more viable for all involved?
If you include the above your idea to allow for mouse input is more likely to be accepted if the reasoning is good. Remember, Alexandre has a game he is making and I am currently toying around with Java game design because the Ouya is coming out soon, so it may be a while before your idea sees the light of day.
If I knew then what I know now I'd tell you that the story's true. Cause whatever you do, it comes back to you. -Slaughter, Burning Bridges
Offline
it's not possible to read the mouse yet, but the request is already on the todo list. Mouse commands aren't hard to build, but that's not top priority at the moment.
today, it's possible to read stuff from the keyboard / joypad.
at the moment i'm messing around with the sunshine paradise brickset (trying to make a better brickset, more or less like this one i got online, but using graphics from sunshine paradise). I'm no pixel art guy, but this must be done asap.
Offline
at the moment i'm messing around with the sunshine paradise brickset (trying to make a better brickset, more or less like this one i got online, but using graphics from sunshine paradise). I'm no pixel art guy, but this must be done asap.
Can I help?
https://discord.gg/w8JqM7m ---> Open Surge's Discord server
Offline
it's not possible to read the mouse yet, but the request is already on the todo list. Mouse commands aren't hard to build, but that's not top priority at the moment.
What about the level editor?
My Souncloud
My YouTube Channel
Offline