are you sure it's only getTexture that can't be found. isn't there any problem with CCTextureCache? by the way I'm not sure if it does apply to java ba usually you can't override static methods.
–
Ali.SSep 30 '11 at 13:07

3

This code shows a severe deficiency at basic understanding of Java and OO, and so is probably off-topic.
–
user744Sep 30 '11 at 13:24

by the way you can can't cast result of CCSprite constructor to CharacterSprite!
–
Ali.SSep 30 '11 at 14:25

@Joe He is a newbie, he'll get subclassing (...) after some time.
–
user712092Oct 12 '11 at 2:23

1 Answer
1

public class CharacterSprite extends CCSprite
{
// Add new custom fields or methods here,
// or override the specific methods of CCSprite
// that you want to extend the functionality of.
}

From your question I can understand that you are inheriting CCSprite not to extend the functionality. Usually this should be avoided. There is no need to override the public static CharacterSprite sprite(String fileName) method as it will be already there in the super class.

So a call like this will do: CharacterSprite.sprite("sample.png"). This will return a sprite you desire!

In fact, There are two ways you can make CharacterSprite class which you desire.

Inheriting CCSprite. Do this only if you are really over-riding any functionality of the existing CCSprite (for example, if you want to draw with multi-texturing , override draw and have your code).

Have CCSprite instance as an attribute (member) of CharacterrSprite class. This is the better way if you are "not re-defining" the functionality of CCSprite.