PDA

View Full Version : [Essentials script] How to make a touch screen


carmaniac
August 19th, 2010, 12:10 PM
Well, this is for all of those people who keep asking how to make a touchscreen using crazyninjaguy's mouse module and dualscreen.
Which I can't link the Mouse module as you have to find it over at planetdev.net.

Well, for those who have his two scripts this is what you need to do.
To make a menu have the mouse function you need to find the loop do of the script and then do this following script:

Mouse.mouse_in_area?(x,y,width,height)

That code there sets up the area of where the mouse is going to be expected.
the x,y are the co-ordinates of where the area is located while the width and height is the area size.
For example:

Mouse.mouse_in_area?(30,30,100,100)

That's an example of a button area for instance.
The structure needed for the button to work would be this:

Mouse.mouse_in_area?(30,30,100,100)
if Mouse.click?(1)#left mouse button
do stuff# This is where you put all of the commands you want to happen
end # ends the check for the left mouse button being clicked
end# ends the check for the mouse being in a certain area.

Well that's all that's really needed to be known about the mouse script.
I will only help those who make an effort to learn :P.

Orangturttle
August 24th, 2010, 07:24 PM
Oh goodness! :D
Thanks bro! I'll be trying my luck with this soon.. haha. :D

Gigatom~
August 25th, 2010, 06:46 AM
Thanks for this.
A question for this: Mouse.mouse_in_area?(x,y,width,height)
Does width,height mean teh width and height from the Picture?

Gigatom~

carmaniac
August 25th, 2010, 06:48 AM
Thanks for this.
A question for this: Mouse.mouse_in_area?(x,y,width,height)
Does width,height mean teh width and height from the Picture?

Gigatom~

Yes it does, sorry for not mentioning that but I will expand this page into more detail when I have time later on in the day.

Gigatom~
August 25th, 2010, 06:50 AM
Okay , thank you very much :D

Poeman
August 25th, 2010, 07:51 AM
D: you have opened new things for the community, I can't believe you're handing them this.

Now is this version 1, 2, or 3?

carmaniac
August 25th, 2010, 11:09 AM
D: you have opened new things for the community, I can't believe you're handing them this.

Now is this version 1, 2, or 3?

Shhh... Poeman XD. If I was giving the community something it would be this:
An script base to making an touchscreen menu although I'm not revealing exactly how to call the script and keep it on the screen :P. That is for those determined game maker enthusiasts. And at the moment version 1.

class Window_Menu < SpriteWindow_Base
def initialize
@sprites = {}
@sprites[""] = Sprite.new
@sprites[""].x =
@sprites[""].y =
@sprites[""].z =

end
def dispose

end
def refresh
if Mouse.mouse_in_area?(x,y,width,height)
if Mouse.click?(1)

end
end

end
end

Pichuichu
August 25th, 2010, 06:23 PM
Who persuaded you to post this? but yes this would help game developers to make touch screen games. Thanks. :)

carmaniac
August 26th, 2010, 05:15 AM
Who persuaded you to post this? but yes this would help game developers to make touch screen games. Thanks. :)

No one, I just felt like posting something like this seeming as only a few people knew how to do it.

matrockista06
August 28th, 2010, 09:20 AM
where do i paste the codes?

Pichuichu
August 29th, 2010, 04:00 PM
may i ask if i put the co-ordinates in the top left corner of where i want?

zingzags
August 31st, 2010, 01:24 PM
may i ask if i put the co-ordinates in the top left corner of where i want?

Mouse.mouse_in_area?(co-ordinate-x,co-ordinate-y, height i think,and width i think of the button)

Pichuichu
August 31st, 2010, 01:37 PM
no that but do i make the co-ordinates the top left corner of the button?

zingzags
August 31st, 2010, 01:54 PM
no that but do i make the co-ordinates the top left corner of the button?

Ya from the top left corner of the very top screen which is (0,0), then lets say u want a button on the bottom screen 20 pixels from each part.
sense there is a top screen and if you are using the spacer thing the start of the bottom screen will be (0,340)

and to make the button 20 pixels apart use (20,360)

Yuoaman
October 31st, 2010, 04:27 PM
Please try to refrain from posting in topics that have not had replies in over two months from now on, Urugamosu.

Closed.