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 Game Development

Reply
 
LinkBack Thread Tools Display Modes
Old 11-01-2011, 09:58 PM   #1 (permalink)
Registered Member
 
Join Date: Dec 2009
Posts: 66
mikelowe is on a distinguished road
Question Game Character Custom Class?

Hi Everyone,

I am wondering how to create a custom class for a game character. Do I use an NSObject? I'm really confused about custom classes.

I want to have a character that I can spawn multiple times on the screen, and have them all behave in the same way.

Right now I am using UIImageViews in my games, but i need to be able to keep track of each character and destroy them individually as necessary.

Please help me

-Michael
mikelowe is offline   Reply With Quote
Old 11-09-2011, 05:04 AM   #2 (permalink)
Registered Member
 
Join Date: Nov 2011
Posts: 1
mobidangel is on a distinguished road
Default

Quote:
Originally Posted by mikelowe View Post
Hi Everyone,

I am wondering how to create a custom class for a game character. Do I use an NSObject? I'm really confused about custom classes.

I want to have a character that I can spawn multiple times on the screen, and have them all behave in the same way.

Right now I am using UIImageViews in my games, but i need to be able to keep track of each character and destroy them individually as necessary.

Please help me

-Michael
not reply
mobidangel is offline   Reply With Quote
Old 11-09-2011, 03:14 PM   #3 (permalink)
Registered Member
 
Join Date: Nov 2011
Posts: 12
Zanzibar7 is on a distinguished road
Default

Quote:
Originally Posted by mikelowe View Post
I want to have a character that I can spawn multiple times on the screen, and have them all behave in the same way.

Right now I am using UIImageViews in my games, but i need to be able to keep track of each character and destroy them individually as necessary.
I'm doing the same type of thing in my game. You need to make a UIImageView for each character you put on the screen, then put them all into an array, then use a for loop to go through the array and do your actions for each character. Then when you want to destroy one, you just remove it from the array and the view. If you want example code for this, I made a post titled "need help looping through an array". Does this help?
Zanzibar7 is offline   Reply With Quote
Old 11-17-2011, 06:19 PM   #4 (permalink)
Registered Member
 
Naughty_Ottsel's Avatar
 
Join Date: Aug 2008
Location: Gillingham, Dorset, UK
Age: 19
Posts: 218
Naughty_Ottsel is on a distinguished road
Send a message via MSN to Naughty_Ottsel
Default

From what I gather you could subclass a UIImageView which instantly gives you all of the methods and properties in a UIImageView anyway plus your own.
__________________
Follow me on Twitter
Naughty_Ottsel is offline   Reply With Quote
Old 11-21-2011, 07:02 PM   #5 (permalink)
Registered Member
 
Join Date: Dec 2009
Posts: 66
mikelowe is on a distinguished road
Default Thanks Everyone!

Thanks everyone! this is exactly the kinds of things I need. I will try subclassing a UIImageView. I think thats more of what I'm going for. I think I will give the array method a try as well.

-michael
mikelowe is offline   Reply With Quote
Old 12-08-2011, 03:10 PM   #6 (permalink)
Registered Member
 
Join Date: Dec 2011
Posts: 17
jdunehew is on a distinguished road
Default

Quote:
Originally Posted by mikelowe View Post
Thanks everyone! this is exactly the kinds of things I need. I will try subclassing a UIImageView. I think thats more of what I'm going for. I think I will give the array method a try as well.

-michael
no don't do that. Add a new file to your project and just make it a class. You don't need a view for a class you want to make.

This is exactly what you need right here: Objective-C creating objects, methods and variables

Teaches you how to create the class and create new objects of the class.
jdunehew is offline   Reply With Quote
Reply

Bookmarks

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: 373
10 members and 363 guests
apatsufas, comicool, Creativ, Dalia, dansparrow, LunarMoon, mer10, Murphy, pbart, Tomsky
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,676
Threads: 94,127
Posts: 402,916
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jleannex55
Powered by vBadvanced CMPS v3.1.0

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