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 8525857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:06:12+00:00 2026-06-11T08:06:12+00:00

I have 2 scenes both the scene shares a same back ground Image so

  • 0

I have 2 scenes both the scene shares a same back ground Image so I have this below code in both scenes init method and added. Everything works prefect. My question is , since the same image file is read twice , allocated memory and deallocated so why cant we store it one common place (spriteManager) using singleton pattern and reuse that instance? If I do this way will the memory will be released when when the scene one get replaced with scene 2.

One this strike my mind is Retain but not sure how and where to handle this retain. If my approach is wrong for handling Common reusable sprite then please suggest me the proper way of doing the same. I am new to this cocos2d so I havent read the concept of sprite sheet , for now I want to keep everything simple.

CCSprite *bg = [CCSprite spriteWithFile:@"bg.png"];

2nd Question , I read while replacing two heavy scene there would be some chances of memory leak due to overlap in releasing first scene memory and allocating the next scene memory. So to avoid this I read we have to give a pause for seconds load a light weight scene (Loading scene). Is that a good solution or the replacing scene itself will not create any problems.

Would be great if there is a good article about this post title (Reusing Sprite & Replacing scene). .

  • 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-11T08:06:13+00:00Added an answer on June 11, 2026 at 8:06 am

    To answer your first question, you don’t need a spriteManager because cocos2D already have a default texture caching mechanism(refer to ccTextureCache class), and when you call spriteWithFile next time it will just load the texture from texture cache. Note: ccTextureCache usually clear its textures when there is a memory warning.

    Secondly there shouldn’t be any memory leaks when replacing scenes if you have deallocated the objects properly. Can you provide a link to where you read about this?

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

Sidebar

Related Questions

I have an image of the background scene and an image of the same
I have a scene, called testScene, it works like this: @interface testScene : myScene
This is maybe unusual so let me set the scene: We have an SVN
I have this segment of code , a lot of things skipped for brevity
I have a hierarchy like this: Scene  - gameWorld (CCLayer Z:0)     - player (CCSprite
I have been toying with this piece of code: QGraphicsLineItem * anotherLine = this->addLine(50,50,
In my iphone application I have two scenes, both of them are view controllers.
I have a storyboard with 2 scenes. Each scene has a segue ctrl+dragged from
I have some scenes set up and already embedded them in the navigation stack
Im a beginner to the Corona SDK. I have 2 scenes A & B.

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.