Hi, I am quite lost and do not know how to get started with this ideas. I would appreciate if you all can help.
Basically, in the games, there will be a set of guiText (A-Z). So what i want the player to do is to drag each alphabets to the box and click check for validty of the word formed.If check correctly then add score else clear the box.
Look at this picture and everything is clear. So any suggestion how could i tackle this??
Check if the player clicks the box (mouse position and bounds/hit test).
If so go into dragging mode.
While in dragging mode update the texts pixel position to reflect the mouse position.
When they let go or move the mouse too fast … stop dragging.
If the letter is in a box when released leave it where it is, if not return to original position (or just leave it if that suits your game).
If the letter is in a box when released put it in a list of GUITexts in that box. Determine its position in this list based on the x position of other GuiTexts in this list.
To check if its a valid combination(word?) create a string out of all the elements of a given boxes list and compare against your dictionary.
That’s a rough algorithm which might get you started. Feel free to ask for specific questions about any components thereof.
Hi JohnnyA, I really don’t know how to get start? Would appreciate if you could provide more detailed help.
Anyway, i have tried reading up what is function HitTest (screenPosition : Vector3, camera : Camera = null) : boolean
if (guiText.HitTest (Vector3(360, 450, 0)))
print (“This gui texture covers pixel 360, 450”);
So for my case, I would need to create an array to store all my guiText? I was thinking for the screenPosition, it is the position where the text will be like when it is being drag by the player?
I have a quick and dirty unity project that I cleaned up and modified it to spell the word “APE” each letter movable, if you want that I can zip it up. I don’t have any place to put it though. It uses gui.Window instead of gui.Text, so its probably not the best way, but what your trying to accomplish is not cpu or video card intensive, so performance wise it doesn’t matter. I just like GUI window 'cause I just studied it and its real easy to make draggable.