Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / GetTextHitTest variation needed to Return the ID of the Text found under the point x,y

Author
Message
Battoad
AGK Developer
17
Years of Service
User Offline
Joined: 12th Feb 2007
Location: A Dark Place
Posted: 16th Jan 2017 18:01
I am making an app which uses quite a few CreateText commands but i need to be able to identify which one has been selected.

The current GetTextHitTest only returns 1 or 0 if you specify a specific "iTextIndex" whereas i would like to be able to return the "iTextIndex" of anyText Hit, similar to "GetSpriteHit( x, y )" returns the sprite hit.

Introducing a for--next loop checking through each iTextIndex is too slow.

I know i could convert everything to sprites but that avoids the objective.

Does anyone know how else a specific iTextIndex can be returned after being selected (hit).

Thanks
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 16th Jan 2017 19:12
it it not nessary to make a test each frame, but you can check after click/touch or each 1/4 sec. or only if the pointer moves.
i would add this text ids into an array and give this array a function, the function loop through all elements and exit fornext if found an id, the func return this id or 0.
else if you make a menu you can divide the mouse y by item count. print(trunc(getpointery() / 10))

function check(myarray ref as integer[],x as float,y as float)

ret =0
for i = 0 to myarray.length
ret=gettexthit(myarray[i],x,y)
if ret then exit
next

endfunction ret
AGK (Steam) V2017.01.09 : Windows 10 Pro 64 Bit : AMD (16.12.1) Radeon R7 265 : Mac mini OS Sierra (10.12.2)
Battoad
AGK Developer
17
Years of Service
User Offline
Joined: 12th Feb 2007
Location: A Dark Place
Posted: 16th Jan 2017 20:06
Hi Markus, Thank you for this work-around. Your solution is something i don't think i would have arrived at on my own so i'm going to give it a go.

Many thanks.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 16th Jan 2017 21:03
i added your suggestion into the feature request thread.
AGK (Steam) V2017.01.09 : Windows 10 Pro 64 Bit : AMD (16.12.1) Radeon R7 265 : Mac mini OS Sierra (10.12.2)

Login to post a reply

Server time is: 2024-04-24 20:58:40
Your offset time is: 2024-04-24 20:58:40