what is the best practice if I have a sprite and want to show it multiple times on the screen?
Each instance should be an individual sprite but they all share the same texture(s).
I think I should use CCSpriteSheed but I can’t seem to get a starting point.
I’ve alredy gone through the forum searching for “reuse sprite”, “same sprite multiple times”, etc. but cannot seem to find an answer, so there must be acompletely different approach I think.
To make it even more complex: the sprites created from this one texture should not only appear multiples times on the screen but be scaled differently too. If I understand correctly, this is not possible with CCSpriteSheet?
Use multiple sprites that use the same texture. Cocos will only load the texture once even though its used many times. For instance when you make a CCSprite with -spriteWithFile:@”someImage.png” it will load “someImage.png” into memory. The next time you create a new CCSprite and call -spriteWithFile:@”someImage.png” it wont reload that image, instead it will reference the texture which already exists in memory.
Krumelur: Groups are virtual. Folder references are not. When you add a folder to your project, it depends on whether you select “recursively create groups” or “create folder references”. You can tell a group from a folder reference in the tree view because folder references are blue. This means everything in groups has to have a unique file name. You can’t have two of the same file name if they are in groups. However, in a folder reference you can, and you have to use the folder path to access it.
@Codemattic@Blue Ether @Krumelur okay, if i wanted to have an app where the user would drag their finger across the screen, and a dot appeared every 10 pixels the user’s finger traveled, how would i accomplish that?? I know you cant just keep repeating:[self addChild:dot]; every 10 pixels, because that would take FOREVER to code. Please help me out, guys! Thanks!