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

  • Home
  • SEARCH
  • 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 8595047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:20:36+00:00 2026-06-12T00:20:36+00:00

I wanted to know more about sub classing a CCSprite and the advantage over

  • 0

I wanted to know more about sub classing a CCSprite and the advantage over just creating the CCSprite on init.

New to iOS dev and Cocos2d.

My game creates several CCSprites on init and clones some of them on touch/drag/collision

Looking for implantation on subclassing as well

UPDATE:

Also my Sprites have a text label as well as an audio file and a image file that differ from each sprite slightly. Example all the sprites have the same image but text and audio are different. And on collision the image file might change

  • 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-06-12T00:20:38+00:00Added an answer on June 12, 2026 at 12:20 am

    When you should subclass CCSprite:

    • almost never
    • only when you have to change how the sprite displays itself (custom draw)

    Sprites are in Cocoa terms “views”. So are all other nodes. The thing is, a Sprite is an object that renders a texture on the screen. Subclassing makes sense if you want to change how the Sprite is drawn, perhaps by blending two textures into one, but adding masking functionality, by running different shader code, by adding custom OpenGL drawing.

    If that’s not clear, ask the same question again but about a different view class:

    "What's the advantage of subclassing UIButton? When does it make sense?"
    

    Answer: only if you need to change how the button displays itself.

    You don’t subclass UIButton to make it move over the screen or to make it perform an action on a text field. That’s the job of a view controller. The view controller allows you to use the view verbatim, as it is, no subclassing. What you want is a view controller, not a subclass of CCSprite. It’s been done way too often already.

    Long story short:

    Subclass CCSprite (etc) only when you can’t make it perform the intended tasks through its public interface.

    Changing position, rotation, scale, texture, sprite frame, etc. are all properties you can change from an outside class (controller). The same goes for animating the sprite, be it with CCAnimation or running actions.

    If you use a controller object like it’s customary in MVC design, you almost never need to subclass CCSprite or any other node class. What’s more, with the userObject property you can store the controller object with the node, so it gets deallocated when the node is deallocated.

    Of course both approaches work, and at the end it only boils down to whether one wants to use best practices, or bad practices.

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

Sidebar

Related Questions

I just wanted to know more about analytics. I am new to this thing.
I really just wanted to know a bit more about the PHP Cli with
Just wanted to know if is possible to use mod_rewrite on a single(or more
Right now I'm learning about the CakePHP framework, and I just wanted to know
I wanted to know more about tools that assist in writing code-generators for C.
I wanted to know about Hadoop more than a black box. I wanted to
I am looking to learn more about threading and I wanted to know: what
I'm learning more then I ever wanted to know about Floating point numbers. Lets
Might be my question sounds more naive. But I wanted to know if it
I wanted to know about Data Type implementation in PHP so I need a

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.