which function to find the id of the sprite or brush click t

Find quick help here to get you started with Hollywood
Post Reply
sinisrus
Posts: 347
Joined: Tue Apr 21, 2015 5:43 pm

which function to find the id of the sprite or brush click t

Post by sinisrus »

Hello,

which function to find the id of the sprite or brush if click with mouse?

thank you
Bugala
Posts: 1390
Joined: Sun Feb 14, 2010 7:11 pm

Re: which function to find the id of the sprite or brush cli

Post by Bugala »

If i udnerstand your question right, then it is not that simple.

What you are probably after, is that you would first make them into a button.

When making that button you could use "userdata" option, and put layer id on that.

That way on button pressed function you could simply use:

layername = msg.userdata


Another way that you could try is to save mousex and mousey co-ordinates of the current location when mouse is clicked.

After that you would make rectangle collision check of each layer, the layer that is colliding with the area, must be under the mouse pointer then. This of course supposing each layer is separate from each other, since if there are multiple layers under mouse pointer at same time, then each would return true for collision check.

Hope this helped something. Felt too tired making actual code examples this time.
zylesea
Posts: 232
Joined: Tue Feb 16, 2010 12:50 am
Location: Westfalen/Germany
Contact:

Re: which function to find the id of the sprite or brush cli

Post by zylesea »

You don't need a button. You always know all positions of your sprites (actually they do have precise coordinates) and you know the position of your mouse by MouseX() and MouseY(). Now you only need to check whether your actual pointer coordinate is within the coordinates of one or several sprite (some loop). Collision detection of a sprite against an X/Y coordinate is to my understanding not possiblem hence the need of checking yourself. Or create a certain 1px helper sprite that gets displayed at the actual mouse coordinates and use collision(#sprite, id1,id2) to check for collision. of course yo need to check every sprite against that mouse pointer coordinate sprite.
Something like that. Of course yo need the actual number of sprites in use. Something like that (just quickly written down, no actual tested code)

Code: Select all

If IsRightMouse() = True
sposX$=MouseX()  
sposY$=MouseY()  
displaysprite(1000,sposX$,sposY$) ;show your "mousesprite"
for i=1 to YourNumberOfSprites$
if collision(#sprite, id1,id2) =true then debugprint("Sprite no.", YourNumberOfSprites$,"is under the mousepointer")
displaysprite(1000,-1,-1) ;remove your mousesprite
next
endif
sinisrus
Posts: 347
Joined: Tue Apr 21, 2015 5:43 pm

Re: which function to find the id of the sprite or brush cli

Post by sinisrus »

@zylesea, Bugala

thank you, I find function for return id of sprite if I put the mouse over the Sprite
Post Reply