View Single Post
Senior Member
Dameria's Avatar
Status: Offline
Posts: 976
Join Date: Sep 2009
Location: United States
Default 11-23-2012, 10:29 AM

Originally Posted by byu rocks23 View Post
Is there a way to make it so it works on all screen sizes?
Yes there is. What I do is that I create two world variables, one for x coordinate and y coordinate (something like xVal and yVal). Then I create any object, I prefer a sphere, and I turn it red (so it's easier to see) and put it in the bottom left of the screen so only half of the sphere can be seen. Then put a 3d text in the center of the screen telling the user to "Click the red sphere". Now make a world method called "getCoords" and inside of that, put ("xVal" set equal to "[mouse distance from the left edge] / 2"). Then put an event in the events board and put "When the mouse is clicked on (sphere), do (getCoord)". Now you have the correct half value x coordinate for any sized screen.

Below is an even more complicated version that I quickly made that gets both x and y values, and creates a simple mouse movement. Actually, I'm looking at my code now, and the part where it gets the midpoint x value is redundant. You don't need to do the whole "click the sphere in the corner" part like I told you in the first part. Instead I used integers for the previous x and y values, and every time the mouse moves, it moves the camera and then sets a new previous x and y value to be used again. I also used a standard object (cube) to control the x coordinate movements, and set the camera vehicled to the cube. The y movement is turned by the camera. The reason the cube is there is to prevent the camera from going sideways when doing a combined right-left and up-down movement. If you don't understand it by looking at the method "mouseMovement", just ask me.
Attached Files
File Type: a2w mouseMovement.a2w (210.6 KB, 16 views)

Check out my best projects so far and please comment:

Tic-Tac-Toe 2.0 ...................
Alice Paint ...........................
Real-Time Clock ..................
Maze Game .........................
Reply With Quote