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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:27:02+00:00 2026-06-06T01:27:02+00:00

I am tring to follow this post post and combine it with the ShootThemUp

  • 0

I am tring to follow this post post and combine it with the ShootThemUp example from
LearnCocos2d. Unfortunately I am a bit confused as I got an issue with animating the parts of a subclass of CCSprite and an issue in accessing to the frame names inside the texture map.

ACCESSING SPRITE FRAME NAMES

I do get the following expection:

CCSpriteFrameCache: Trying to use file 'game-art.png' as texture

when trying to access the frame name as in the ShootEmUp example:

head = [CCSprite initWithSpriteFrameName:@"head.png"];

Here is the modified code:

@implementation ShipEntity

@synthesize lifes;

+(id) ship
{
    self = [[[self alloc] init] autorelease];
    [self addParts];
    return self;
}

-(void) addParts
{

    [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"game-art.plist"];



    body = [CCSprite node];
//      head = [CCSprite spriteWithSpriteFrame:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:@"head.png"]];

    head = [CCSprite initWithSpriteFrameName:@"head.png"];

    [head setPosition:CGPointMake(10,10)];
    [body addChild:head];
    [self addChild:body];
/**
    // create an animation object from all the sprite animation frames
    CCAnimation* anim = [CCAnimation animationWithFrame:@"head-anim" frameCount:3 delay:0.08f];

    // add the animation to the sprite (optional)
    [head addAnimation:anim];

    // run the animation by using the CCAnimate action
    CCAnimate* animate = [CCAnimate actionWithAnimation:anim];
    CCRepeatForever* repeat = [CCRepeatForever actionWithAction:animate];
    [head runAction:repeat];
    **/
    [self scheduleUpdate];

    //should use spawn method..
    initialHitPoints=2;
    hitPoints=initialHitPoints;
    lifes=3;
    [[GameScene sharedGameScene] setLifeCount:lifes];

}

If I do replace:

head = [CCSprite initWithSpriteFrameName:@"head.png]; 

with

head = [CCSprite spriteWithSpriteFrame:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:@"head.png"]];

then it does add it. Why do I need to do this? In the ShootthemUp example it did work by accessing the sprite frame name directly.I think I need to find a way to make the plst file visible withing all the source code I am writing..

ANIMATION ISSUE
Finally, I tried to add an animation by uncommenting the following bit of code (assume I do have the head-anim files in the game-art.png and game-art.plist files:

        CCAnimation* anim = [CCAnimation animationWithFrame:@"head-anim" frameCount:3 delay:0.08f];

    // add the animation to the sprite (optional)
    [head addAnimation:anim];

    // run the animation by using the CCAnimate action
    CCAnimate* animate = [CCAnimate actionWithAnimation:anim];
    CCRepeatForever* repeat = [CCRepeatForever actionWithAction:animate];
    [head runAction:repeat];

But it did not work.. any suggestion?

This is the stacktrace of the exception:

012-02-28 12:15:14.068 ShootEmUp[26182:40b] cocos2d: CCSpriteFrameCache: Trying to use file 'game-art.png' as texture
2012-02-28 12:15:14.109 ShootEmUp[26182:40b] cocos2d: CCSpriteFrameCache: Trying to use file 'game-art.png' as texture
2012-02-28 12:15:14.109 ShootEmUp[26182:40b] +[CCSprite initWithSpriteFrameName:]: unrecognized selector sent to class 0x10cbf0
2012-02-28 12:15:14.111 ShootEmUp[26182:40b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[CCSprite initWithSpriteFrameName:]: unrecognized selector sent to class 0x10cbf0'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x013f0be9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x015455c2 objc_exception_throw + 47
    2   CoreFoundation                      0x013f27bb +[NSObject(NSObject) doesNotRecognizeSelector:] + 187
    3   CoreFoundation                      0x01362366 ___forwarding___ + 966
    4   CoreFoundation                      0x01361f22 _CF_forwarding_prep_0 + 50
    5   ShootEmUp                           0x0000c7cd -[ShipEntity addParts] + 349
    6   ShootEmUp                           0x0000c64d +[ShipEntity ship] + 141
    7   ShootEmUp                           0x000038ae -[GameScene initWithId:] + 1102
    8   ShootEmUp                           0x00003413 +[GameScene sceneWithId:] + 131
    9   ShootEmUp                           0x00010e9f -[Navigator LaunchLevel:] + 143
    10  CoreFoundation                      0x0136167d __invoking___ + 29
    11  CoreFoundation                      0x01361551 -[NSInvocation invoke] + 145
    12  ShootEmUp                           0x0004be75 -[CCMenuItem activate] + 85
    13  ShootEmUp                           0x00012d86 -[SlidingMenuGrid ccTouchEnded:withEvent:] + 454
    14  ShootEmUp                           0x000a40b1 -[CCTouchDispatcher touches:withEvent:withTouchType:] + 1633
    15  ShootEmUp                           0x000a4bff -[CCTouchDispatcher touchesEnded:withEvent:] + 111
    16  ShootEmUp                           0x000a6ab1 -[EAGLView touchesEnded:withEvent:] + 113
    17  UIKit                               0x008a30d1 -[UIWindow _sendTouchesForEvent:] + 567
    18  UIKit                               0x0088437a -[UIApplication sendEvent:] + 447
    19  UIKit                               0x00889732 _UIApplicationHandleEvent + 7576
    20  GraphicsServices                    0x02998a36 PurpleEventCallback + 1550
    21  CoreFoundation                      0x013d2064 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
    22  CoreFoundation                      0x013326f7 __CFRunLoopDoSource1 + 215
    23  CoreFoundation                      0x0132f983 __CFRunLoopRun + 979
    24  CoreFoundation                      0x0132f240 CFRunLoopRunSpecific + 208
    25  CoreFoundation                      0x0132f161 CFRunLoopRunInMode + 97
    26  GraphicsServices                    0x02997268 GSEventRunModal + 217
    27  GraphicsServices                    0x0299732d GSEventRun + 115
    28  UIKit                               0x0088d42e UIApplicationMain + 1160
    29  ShootEmUp                           0x00002844 main + 100

It seems related to not finding the file but I can’t understand why in the example it does find it and why in my code doesn’t .. I know is a bit silly and there must be an obvious reason that I am missing. Is also the first time I try to generate a plst and png file and hence I might have done some errors..

[EDIT NOTE: Difference in settings between my game-art files -left image- and the ShootthemUp ones – right image]

difference in game-art.plist files

  • 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-06T01:27:03+00:00Added an answer on June 6, 2026 at 1:27 am

    Thanks for the answer, I haven’t accepted it as the reason for which I was having problem was relatead to this other question post that I asked.. I did not realize that I needed both -hd and not -hd file in the App which was causing the confusing (I had added only one sprite atlas file in the resource folder and whenver I was trying to access a frame within it the App was complaining as it was set to run on retina display and wasn’t finding both resource files). I wouldn’t have imagined that without the answer I received in the post 1.

    Thanks for your help!

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

Sidebar

Related Questions

I am trying to follow this example (from p137 of Rob Pickering's Foundations of
I'm trying to follow the example in this post by tvanfosson . I just
I have been trying to follow the example in this post . Since I
Trying to follow this example. (Section String sorting...) Is there anything obvious that would
I am new to maven and I am trying to follow this example but
This is a follow-on from this question, in which I was trying to suppress
I'm trying to follow this blog post: http://blogs.msdn.com/b/carlosfigueira/archive/2011/04/19/wcf-extensibility-message-inspectors.aspx My aim is to somehow get
I'm trying to follow the instructions laid out in this post , but I'm
This is a follow-up question of my previous post . I am trying to
I've been trying to follow this blog post to get my python version back

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.