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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:14:41+00:00 2026-05-14T00:14:41+00:00

I’m trying to draw two sprites on the same screen. I have defined the

  • 0

I’m trying to draw two sprites on the same screen. I have defined the two sprite objects in two separate class files.

  1. If I comment out two lines (see “item 1” comment below) then I get a display as [a backgroundimage[background2.jpg] with a sprite[grossini.png] on the left side.
  2. If I uncomment the two lines I do not get the background image and sprite of (gameScreen.m). I get only the sprite [grossinis_sister1.png] defined in (enemy.m).
  3. But what I need is a [backgroundimage[background2.jpg]], sprite[grossini.png] and sprite [grossinis_sister1.png] in one screen.

This is implementation file of my first class:

#import "gameScreen.h"

#import "enemy.h"
@implementation gameScreen

-(id)init
{
    if((self = [super init]))
    {
        CCSprite *backGroundImage = [CCSprite spriteWithFile:@"background2.jpg"];
        backGroundImage.anchorPoint = ccp(0,0);
        CCParallaxNode *voidNode = [CCParallaxNode node];
        [voidNode addChild:backGroundImage z:-1 parallaxRatio:ccp(0.0f,0.0f) positionOffset:CGPointZero];   

        [self addChild:voidNode];

        CGSize windowSize = [[CCDirector sharedDirector] winSize];

        CCSprite *player = [CCSprite spriteWithFile:@"grossini.png"];
        player.position = ccp(player.contentSize.width/2, windowSize.height/2);

        [self addChild:player z:0];
        //eSprite = [[enemy alloc]init]; //<-- see item 1             
        //[self addChild:eSprite];      
    }

    return self;
}

This is my implementation file of my second class:

#import "enemy.h"

#import "gameScreen.h"
@implementation enemy
-(id)init
{
    if ((self = [super init]))
    {
        CGSize windowSize = [[CCDirector sharedDirector] winSize];

        CCSprite *enemySprite = [CCSprite spriteWithFile:@"grossinis_sister1.png" ];
        enemySprite.position = ccp(windowSize.width/2, windowSize.height/2);

        [self addChild:enemySprite];
    }
    return self;
}
@end
  • 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-14T00:14:41+00:00Added an answer on May 14, 2026 at 12:14 am

    The high level understanding you need is this. A screen contains 1 or many layers a layer contains sprites.

    So create a screen and then add a layer to it and add the sprites to the layer you created. Of course one can have many screens and a screen can consists of many layers. But in a simple demo game create 1 screen, 1 layer, and add sprites to that layer.

    See this link for more detail http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:basic_concepts.

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

Sidebar

Ask A Question

Stats

  • Questions 369k
  • Answers 370k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I would follow the tutorials on the jquery site, they… May 14, 2026 at 6:31 pm
  • Editorial Team
    Editorial Team added an answer it's your the server or it's hosted ? anyway the… May 14, 2026 at 6:31 pm
  • Editorial Team
    Editorial Team added an answer One approach would be to simply do a backup and… May 14, 2026 at 6:31 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.