Jump to content


Photo
* * * * - 7 votes

[Studio] Touch Screen Controls


  • Please log in to reply
47 replies to this topic

#1 iSeiren

iSeiren

    www.worrall.pw

  • GMC Member
  • 610 posts
  • Version:GM:Studio

Posted 13 November 2011 - 11:45 PM

  • Title: Touch Screen Controls
  • Description: Allows your users to use a touch screen to control the game
  • GM Version: GM:Studio
  • Registered: yes
  • File Type: .zip
  • File Size: 84kb
  • File Link: DOWNLOAD
  • Required Extensions: N/A
  • Required DLLs: N/A

Summary


UPDATED TO THE LATEST VERSION OF GAME MAKER STUDIO.

This example wont be useful to a lot of you, but it will be useful for those who wish to develop games for Touch Screen devices - such as the iPad or Android tablets. You get on-screen buttons which you can click/press. This sends a virtual key press to the game which in turn activates any key-press events you have.

Short and sweet. The link below is for a live demo of the tutorial. Enjoy.

DEMO -Dead link, will be back soonTM

Spoiler

Edited by iSeiren, 21 May 2014 - 09:12 AM.

  • 8

#2 _230411

_230411

    GMC Member

  • New Member
  • 13 posts

Posted 18 November 2011 - 04:11 AM

Does it support Multi-Touch?
  • 0

#3 iSeiren

iSeiren

    www.worrall.pw

  • GMC Member
  • 610 posts
  • Version:GM:Studio

Posted 25 November 2011 - 10:52 PM

Does it support Multi-Touch?


Yes :). (For the controls) So you could add a jump or fire button.



  • 1

#4 NeoTalon27

NeoTalon27

    GMC Member

  • GMC Member
  • 220 posts
  • Version:GM:HTML5

Posted 04 January 2012 - 11:08 AM

Awesome, I have been looking for something like this :biggrin:
+1
  • 0

#5 njp

njp

    Panda

  • GMC Member
  • 2340 posts
  • Version:GM8

Posted 07 January 2012 - 07:17 AM

*clap clap clap* +1 Posted Image
however id recommend using this to adjust the views (its smoother for me and has less bugs, i edited this from another example given to me a few weeks ago):
if ( (view_wport != browser_width) || (view_hport != browser_height) )
{
	view_xview[0] = 0;
	view_yview[0] = 0;
	view_wview[0] =  browser_width
	view_hview[0] =  browser_height

	
	view_xport[0] = 0;
	view_yport[0] = 0;
	view_wport[0] =  browser_width
	view_hport[0] =  browser_height}

Edited by njp, 07 January 2012 - 07:18 AM.

  • 0

#6 iSeiren

iSeiren

    www.worrall.pw

  • GMC Member
  • 610 posts
  • Version:GM:Studio

Posted 07 January 2012 - 01:26 PM

*clap clap clap* +1 Posted Image
however id recommend using this to adjust the views (its smoother for me and has less bugs, i edited this from another example given to me a few weeks ago):

if ( (view_wport != browser_width) || (view_hport != browser_height) )
{
	view_xview[0] = 0;
	view_yview[0] = 0;
	view_wview[0] =  browser_width
	view_hview[0] =  browser_height

	
	view_xport[0] = 0;
	view_yport[0] = 0;
	view_wport[0] =  browser_width
	view_hport[0] =  browser_height}


The main focus of the tutorial is the controls, not the game filling the screen. But thanks for posting it - maybe people will find it useful ^^.
  • 0

#7 KaloyanBeshev

KaloyanBeshev

    GMC Member

  • GMC Member
  • 21 posts
  • Version:GM:Studio

Posted 21 November 2012 - 03:10 PM

Perfect, thank you. Will try them first thing tommorow morning :) !
  • 0

#8 elsato

elsato

    GMC Member

  • GMC Member
  • 43 posts
  • Version:GM:Studio

Posted 22 November 2012 - 09:00 AM

hey this is useful! thanks! :>
  • 0

#9 elsato

elsato

    GMC Member

  • GMC Member
  • 43 posts
  • Version:GM:Studio

Posted 28 December 2012 - 05:27 PM

hey!
just today had the chance to try it on android, and i get this error in the device

ERROR in
action number 1
of Step Event2
for object obj_fitwindow:

illegal virtual key handle


this happens when i press any of the virtual keys

Edited by elsato, 28 December 2012 - 05:27 PM.

  • 0

#10 iSeiren

iSeiren

    www.worrall.pw

  • GMC Member
  • 610 posts
  • Version:GM:Studio

Posted 28 December 2012 - 05:45 PM

Yeh it needs updating. I'll sort it soon
  • 0

#11 iSeiren

iSeiren

    www.worrall.pw

  • GMC Member
  • 610 posts
  • Version:GM:Studio

Posted 29 December 2012 - 01:36 PM

I have updated this to work with the latest version of Game Maker Studio.
  • 0

#12 Nocturne

Nocturne

    Nocturne Games

  • Administrators
  • 20894 posts
  • Version:GM:Studio

Posted 31 December 2012 - 09:19 AM

Given the fact that this is a great little tutorial and that many people in need of this information, I'm moving this into the staff pick section of the forums. Well done!!!
  • 0

#13 Genaut

Genaut

    GMC Member

  • GMC Member
  • 139 posts
  • Version:GM:Studio

Posted 23 February 2013 - 09:49 AM

Nice example. Thanks a lot! I dont see any code in the game maker file that allows touch the sprites... the example .exe works great but the game maker project no!

Edited by Genaut, 23 February 2013 - 02:29 PM.

  • 0

#14 matidefa

matidefa

    GMC Member

  • New Member
  • 5 posts
  • Version:GM:Studio

Posted 08 March 2013 - 11:54 PM

how to install the extension and dll: N / A?
  • 0

#15 iSeiren

iSeiren

    www.worrall.pw

  • GMC Member
  • 610 posts
  • Version:GM:Studio

Posted 08 March 2013 - 11:56 PM

N/A means Not Applicable, meaning you don't need to do anything :).
  • 0

#16 matidefa

matidefa

    GMC Member

  • New Member
  • 5 posts
  • Version:GM:Studio

Posted 09 March 2013 - 02:41 AM

then what happens? when I try it on windows do not work that does not move?

sorry for my bad English
  • 0

#17 iSeiren

iSeiren

    www.worrall.pw

  • GMC Member
  • 610 posts
  • Version:GM:Studio

Posted 14 March 2013 - 08:41 PM

This won't work on Windows, you will have to test it on a mobile or HTML5.
  • 0

#18 Brano000

Brano000

    Indie Game Developer

  • GMC Member
  • 150 posts
  • Version:GM:Studio

Posted 03 April 2013 - 02:27 PM

Thank You very much! ^^


  • 0

#19 mizerr

mizerr

    GMC Member

  • GMC Member
  • 41 posts
  • Version:GM:Studio

Posted 23 April 2013 - 11:35 PM

AWESOME! Thank you very much for the tutorial, helped me past an annoying issue! rep given.


  • 0

#20 iSeiren

iSeiren

    www.worrall.pw

  • GMC Member
  • 610 posts
  • Version:GM:Studio

Posted 27 April 2013 - 10:41 AM

That hasn't changed, in your Menu room - put your button object with the mouse left pressed event as    room_goto("GameRoom");

 

GameRoom being the name of the room you want to go to.

 

 

 

The idea behind this tutorial allows users the use of multi-touch buttons etc. Menu buttons don't need this feature. There are other reasons too.


  • 0

#21 iSeiren

iSeiren

    www.worrall.pw

  • GMC Member
  • 610 posts
  • Version:GM:Studio

Posted 27 April 2013 - 06:38 PM

For simple buttons, just left pressed.


  • 0

#22 dark3000light

dark3000light

    GMC Member

  • GMC Member
  • 37 posts
  • Version:GM:Studio

Posted 19 May 2013 - 04:48 PM

How do I reverse the position of the keys? So they appear on the left side of the screen instead?


  • 0

#23 Dralger

Dralger

    GMC Member

  • GMC Member
  • 34 posts
  • Version:GM:Studio

Posted 14 September 2013 - 05:29 AM

hey!
just today had the chance to try it on android, and i get this error in the device

ERROR in
action number 1
of Step Event2
for object obj_fitwindow:

illegal virtual key handle


this happens when i press any of the virtual keys

 

I am getting the same exact error, they keys are showing up on my phone and all looks good but it crashes immediately with this error.


  • 0

#24 emartinez1986

emartinez1986

    GMC Member

  • New Member
  • 18 posts
  • Version:GM:Studio

Posted 12 October 2013 - 05:58 AM

Yes, don't copy code, try to understand it... then you don't need examples, only your brain. Steps to create code - think what you want to do:

1. What you need to move screen? Put finger on screen and move finger.
2. How to check that finger is moved? Check distance and direction from starting point, while finger is touching screen.
3. When to stop moving? When finger will stop touching screen. It's release event.

So, now:

On MousePressLeft - assign to some variables: current x, y, and that moving started (moving = true or something).
On MouseLeft - if moving = true, you can move view on x/y axis, checking direction from point x,y that you previously saved, to point x,y of mouse now - lenghtdir_x/y will be helpful here (where len will be speed, and dir will be... direction of course). You can put argument, that screen will start to move after some distance from begining point.
On MouseReleaseLeft = moving = false and that's all

Now you've got nearly ready code - just write it :)


  • 0

#25 divyanshkumar

divyanshkumar

    GMC Member

  • New Member
  • 6 posts
  • Version:GM:Studio

Posted 30 October 2013 - 05:07 PM

hi please re-upload your file it . when i click on the link it says "the file not found". please do it it will help me a lot.


  • 0

#26 2d_warrior

2d_warrior

    GMC Member

  • GMC Member
  • 243 posts
  • Version:GM8

Posted 24 November 2013 - 04:14 AM

This won't work on Windows, you will have to test it on a mobile or HTML5.

 

Not at all, or just without a touchscreen?


  • 0

#27 iSeiren

iSeiren

    www.worrall.pw

  • GMC Member
  • 610 posts
  • Version:GM:Studio

Posted 08 December 2013 - 06:39 PM

 

This won't work on Windows, you will have to test it on a mobile or HTML5.

 

Not at all, or just without a touchscreen?

 

 

The windows compiler wont compile virtual keys.


  • 0

#28 dm3

dm3

    GMC Member

  • GMC Member
  • 40 posts
  • Version:GM:Studio

Posted 12 January 2014 - 01:08 AM

thank u


  • 0

#29 vidokas

vidokas

    GMC Member

  • GMC Member
  • 283 posts
  • Version:GM8

Posted 26 February 2014 - 06:40 PM

did it would be possible to make that users can draw line or something?
like user touches screen and moves finger trough display and that line would appear in game?


maybe with some checkpoints or something similer
*_____*____*____*
|           |

|           |

*_____*

* - touch


i even found game for explain what ask
http://www.lessmilk.com/7/


Edited by vidokas, 27 February 2014 - 11:31 PM.

  • 0

#30 iSeiren

iSeiren

    www.worrall.pw

  • GMC Member
  • 610 posts
  • Version:GM:Studio

Posted 01 March 2014 - 06:41 PM

did it would be possible to make that users can draw line or something?
like user touches screen and moves finger trough display and that line would appear in game?


maybe with some checkpoints or something similer
*_____*____*____*
|           |

|           |

*_____*

* - touch


i even found game for explain what ask
http://www.lessmilk.com/7/

 

While i could make a game link this, i don't think it's relevant to this tutorial.

 

I'd help you with it, but right now I'm extremely busy.

 

Ask on the forums, I'm sure somebody can help :).


  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users