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 04-06-2011, 01:27 PM   #1 (permalink)
Registered Member
 
Join Date: Apr 2011
Location: Roseville, CA
Posts: 1
Quinnland23 is on a distinguished road
Default Arrays as slots

With games that require slots and pieces I'd generally use a pointer array for the slots, initialize them with NULL and then fill them with a pointer to the piece that later occupies them. This makes it easy to check if slot 2 is empty or replace an item in slot 4.

This seems to be problematic in Objective C due to the dynamic nature of NSMutableArray and ccArray and the inability to assign NULL/nil to an index. Is there a simple solution or similar trick for Objective C / Cocos2d?
Quinnland23 is offline   Reply With Quote
Old 04-06-2011, 02:03 PM   #2 (permalink)
Super Moderator
 
Join Date: Oct 2009
Location: San Diego, CA
Posts: 1,586
JasonR is on a distinguished road
Default

You can place an NSNull object into an NSMutableArray instead to represent a blank slot. I imagine there's something similar for a ccArray.
__________________
My development blog: http://jrinn.com
JasonR 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: 428
6 members and 422 guests
chemistry, Emy, hussain1982, mistergreen2011, Retouchable, skrew88
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,679
Threads: 94,128
Posts: 402,922
Top Poster: BrianSlick (7,990)
Welcome to our newest member, xzoonxoom
Powered by vBadvanced CMPS v3.1.0

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