Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 03-31-2011, 04:10 PM   #1 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 10
allenjones2003 is on a distinguished road
Default how to add touch event to whole screen in Corona

Hi,

im still kinda new to Corona but making some very good progress, im making a simple game and one part of the game involves an object moving from side to side in a loop at the top of the screen and i want to add a touch even so that when anywhere on the screen is touched it stops the loop and the object then falls ( i already have all the physics code in place just struggling with this bit!)

any help would be very appreciated!

many thanks!
Allen
allenjones2003 is offline   Reply With Quote
Old 03-31-2011, 04:32 PM   #2 (permalink)
Registered Member
 
Jay Jennings's Avatar
 
Join Date: Jan 2009
Posts: 28
Jay Jennings is on a distinguished road
Default

If you have a background image you can put the touch on that:

bgImage:addEventListener("touch", bgImageTouched)

... where bgImageTouched is the function to be called when the image was touched.

Or, with no background image try something like:

Runtime:addEventListener("touch", screenTouched)

... where screenTouched is the function to be called when anywhere on the screen was touched.

Jay Jennings
__________________
Game Dev Nation - Tips and tutorial for Corona SDK developers. http://GameDevNation.com
Jay Jennings is offline   Reply With Quote
Old 04-04-2011, 02:33 PM   #3 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 10
allenjones2003 is on a distinguished road
Default

Quote:
Originally Posted by Jay Jennings View Post
If you have a background image you can put the touch on that:

bgImage:addEventListener("touch", bgImageTouched)

... where bgImageTouched is the function to be called when the image was touched.

Or, with no background image try something like:

Runtime:addEventListener("touch", screenTouched)

... where screenTouched is the function to be called when anywhere on the screen was touched.

Jay Jennings
Hi Jay,

sorry for the delay but haven't been near a computer for a couple days and just getting back into this, i've added the Runtime:addEventListener("touch", screenTouched) code as the background will be covered with other objects so wouldn't be much use adding the touch event to it.. but nothing happens when I click the simulator anywhere on screen, does it need to be at the beggining of the code or do i need to add any other functions ??

thanks for your help!
Allen
allenjones2003 is offline   Reply With Quote
Reply

Bookmarks

Tags
corona, touch, whole screen

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 370
12 members and 358 guests
condor304, dansparrow, dre, ilmman, LezB44, michelle, Objective Zero, samdanielblr, Sami Gh, shagor012, thephotographer, tinamm64
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,663
Threads: 94,119
Posts: 402,896
Top Poster: BrianSlick (7,990)
Welcome to our newest member, LezB44
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:37 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0