Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3930622
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T23:16:28+00:00 2026-05-19T23:16:28+00:00

Background: I’m developing a game for the iPhone/iPad using cocos2d-iphone. Our engine provides the

  • 0

Background: I’m developing a game for the iPhone/iPad using cocos2d-iphone. Our engine provides the ability for the level designer to create new bad-guys by defining a number of properties such as speed, AI, weapons and main sprite texture in .plist files.

Problem: Currently, we build an NSDictionary of all of the prototypes before the level starts. For each entity we store a class name and an NSDictionary describing the parameters required to build a new instance of this entity. We create an instance of each prototype at load time to precache textures but destroy it immediately. When a new bad guy spawns, we use the stored NSDictionary and pass it to the init method like so (stripped of error checking for brevity);

IKPrototype* prototype = [prototypes objectForKey:prototypeID]; 
IKBaseEntity* entity = [[[NSClassFromString([prototype prototypeClass]) alloc] init] autorelease];
[entity setPrototypeID:prototypeID];
[entity parseParameters:[prototype parameters]];
return entity;

Now, this works a treat – but creating a number of bullets in the same frame causes noticeable slow down (a frame or two dropped) as the engine parses the parameters (sometimes 20-30 values). However, they’re essentially the same every time and only change when added to the world (which happens later).

Question: What would be the most efficient method to store a prototype object for later duplicates to be spawned. Would serialization/deserialization work with a subclass of a CCNode, and would it be any quicker than what I’m doing? Would it be better to store a copy of the final object in my prototype class, and then do a ‘deep copy’ of that object for spawning? Would I have to worry about CCTexture references if I did this? Please briefly explain the required steps for a proposed solution.

Have been trying to think of the most efficient method for solving this problem for a while. I’m wondering if there’s a method I’ve not thought of above that might be better? Thanks for reading this far.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T23:16:28+00:00Added an answer on May 19, 2026 at 11:16 pm

    One approach I’ve taken is to pre-create a bunch of objects while you are loading resources for the first time (say in init), the co-opting one of those resources at run-time by just changing its parameters and moving it from an array of inactive objects to active objects.

    You might not have created enough, of course, but if these objects are sharing textures, etc. then you might want to create them as members of a CCBatchNode anyway and make it even more efficient to draw many of them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Background: At my company we are developing a bunch applications that are using the
Background I am writing and using a very simple CGI-based (Perl) content management tool
Background I am trying to create a copy of a business object I have
Background I have been asked by a client to create a picture of the
Background: I have a little video playing app with a UI inspired by the
Background: Some time ago, I built a system for recording and categorizing application crashes
Background: I need to reserve an amount of memory below 0xA0000 prior to my
Background I have a massive db for a SharePoint site collection. It is 130GB
Background: Over the next month, I'll be giving three talks about or at least
Background I work for a large organization which has thousands of MS Access applications

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.