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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 03-29-2009, 01:20 PM   #33 (permalink)
smasher
Senior Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
Default

Quote:
Originally Posted by .mb View Post
I've been following this thread for a while, and I have a question. How would you only target once instance of the newEnemy? For instance if I wanted to just be able to touch one and delete that one.
Short question, long answer - to get the UIImageView to respond to touches, you'll have to subclass UIImageView. Inside your subclass, you'll want to do self.userInteractionEnabled=YES and implement the "touchesEnded:withEvent:" method from UIResponder.

You could also use UIButtons instead, which would let you define a button action - but long-term, subclassing UIImageView will allow you to add other variables you might need (like separate direction/velocity) to each enemy / ball / whatever.

EDIT: you don't have to subclass. Your viewController will get the touchesEnded:withEvent: message, and you could loop through the objects to see which one the touch intersects.
__________________

Free Games!

Last edited by smasher; 12-11-2009 at 01:42 AM. Reason: touchesEnded:withEvent:
smasher is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 158,868
Threads: 89,225
Posts: 380,691
Top Poster: BrianSlick (7,129)
Welcome to our newest member, stokesreece
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:19 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.