Questions tagged [cocos2d-iphone]

1

votes
2

answer
6.8k

Views

Cocos2d-x - Understanding positioning sprites on screen

Can anyone provide some basic pointers on placing CCSprites on screen? Example: CCSize s = CCDirector::sharedDirector()->getWinSize(); With s, say I wanted to position a sprite on the very bottom of the screen starting at 0, think something like grass. if I am running at 1024 x 768, middle is: set...
Jason
1

votes
1

answer
161

Views

Difference between self.variableName and _variableName

I have code like this: MyClass.h @interface MyClass : CCLayer { } @property (nonatomic, retain) CCSprite *spriteName; //retain count = 1 @property (nonatomic, retain) CustomClass *customVariable; //retain count = 1 @end MyClass.m @implementation MyClass @synthesize spriteName; @synthesize customVar...
Moo33
1

votes
1

answer
773

Views

CCRenderTexture and CCDirector render differently?

i wanted to use CCRenderTexture in my project because i have a lot of CCLabelBMFont that are mostly static. Adding them all to my Scene caused some performance issues (Yes you can use BatchNotes etc. but it didnt really help). So I rendered them into a single Texture which increased the performance...
eyeballz
1

votes
1

answer
505

Views

Cocos2d and usage of CCAnimationCache

I'd like to understand the usage of CCAnimationCache. I have a cache of enemies objects. Each object has two CCAnimations member variables, a standard animation and a special animation. The frames in the animation varies according to the type property of the enemy object. @interface EnemyEntity : E...
mm24
1

votes
3

answer
411

Views

Why is this C array NULL when indirectly called in my Objective-C code? (cocos2d)

i have two Objective-C classes, say ParentLayer and ChildLayer. in my child instance, i want to access a C-Array in my parent instance. so i have something like this in my cocos2d code: #define kNumOfElements 10 @implementation ParentLayer{ int array[kNumOfElements]; } -(id)init{ //... for(int i=0;i
David T.
1

votes
1

answer
708

Views

Cocos2d Sprite Movement Speed [closed]

I have a class which creates a sprite at a random point on the screen, this sprite then moves to the center of the screen. How can I make it so that it always travels at the same speed? obviously CCMoveTo* move = [CCMoveTo actionWithDuration:5 position: ccp(screenWidth/2, screenHeight/2)]; Will a...
Kyle Goslan
1

votes
2

answer
56

Views

cocos2d I want my image is displayed once

I have an application cocos2d. I want my image is displayed once. Not every time I go in cocos2d view.Do you have any idea?
Emilie
1

votes
1

answer
645

Views

Cannot initialize a parameter of type CCScene COCOS2D

I just use code to push scene from one scene to another. Here is my code. SettingScene *setting=[SettingScene node]; [[CCDirector sharedDirector]pushScene:setting]; I have used same above other method that works fine but in this line it shows error... /Users/jellyfishtechnologies/Desktop/Vivek/My Ga...
user1791574
1

votes
3

answer
522

Views

identify a sprite from ccarray cocos2d

I added three type of sprite in ccarray. CCArray *storeObject=[[CCArray alloc]initWithCapacity:10]; CCSprite *sprite1=[CCSprite spriteWithFile:@"sprite1.png"]; CCSprite *sprite2=[CCSprite spriteWithFile:@"sprite2.png"]; CCSprite *sprite3=[CCSprite spriteWithFile:@"sprite3.png"]; [storeObject addObje...
user1791574
1

votes
1

answer
1.4k

Views

Texture Packer pvr.ccz files

Can Texture Packer's pvr.ccz files be used in a non cocos2d app? I'd like to use them with core animation. Is this possible?
JVC
1

votes
2

answer
695

Views

Cocos2d: graphics tool

I started to learn Cocos2d to develop games and also Box2d; I read some tutorials and I seen that are used two couples of tool "LevelHelper-SpriteHelper" & "PhysicsEditor-TexturePacker". I noticed that LevelHelper-SpriteHelper are more "simply" and organize levels and physics objects very well. Whil...
CrazyDev
1

votes
2

answer
901

Views

Cocos2D + Disabling only Retina iPad Graphics

I'm running into an issue now when exporting my cocos2d based games out of Xcode 4.3+. While I'm not intending on including iPad Retina graphics with my game, it seems the game wants Retina iPad graphics and is now loading everything incorrectly on iPad Retina Only. Is there a quick and simple way t...
Mike Result
1

votes
1

answer
1.4k

Views

How to pause and resume in Cocos2d

So my idea is have a special bullet that freezes the enemies, and after a period of time the enemies unfreeze itself and continue with their actions/animations. Here's a simple version of what I did: -(void)update:(ccTime)dt { CCSprite *enemySprite; CCARRAY_FOREACH(enemies, enemySprite) { if (CGRect...
user1817517
1

votes
2

answer
1.7k

Views

Hardware Volume buttons change in app volume

So in my app i would like to change the in app volume leves for an alarm by the use of the hardware buttons but whenever i use the buttons to turn up or down the volume it ONLY changes the "ringer" volume wich does NOT effect my in app volume. Under Settings -> Sounds the "change with buttons" swit...
zylski
1

votes
1

answer
2.4k

Views

iAd banner not clickable if banner moves

I have an iAd banner working in a Cocos2d app. Here's the code for a CCLayer subclass I made to show ads. On DidLoad, the add becomes visible and the bottom menu slides up to compensate. -(id) init { if( (self=[super init]) ) { CGSize size = [[CCDirector sharedDirector] winSize]; UIViewController *c...
AlexQueue
1

votes
2

answer
731

Views

.png images make my app size very large

I have a lot of .png images of 5-4-3 mb each, and they made a total of around 50-60mb Has someone got a way to compress .png images to make my app smaller? I was using "PNGenius" but it doesn't make a lot of difference.
Vergmort
1

votes
2

answer
601

Views

Cocos2d and SpriteBatchNode: cannot identify which sprite frame is causing an Assertion to fail

I have already asked something similar but I can't figure out properly how to debug this. That's the question. I added some Exceptions handler (catches all Objective-C) exceptions and that's the result of what I see: The problem is with the setTexture method and it fails at the assertion verifying w...
mm24
1

votes
1

answer
96

Views

cant refrence an int inside array

I am trying to insert an int into the array number but it wont work. int middlePointx[3] = { 350, 400, 460 }; int imHere = 0; imHere = 0; joystick1.position = ccp(middlePointx[imHere].x,startingPoint1.y); I get a member reference base type int is not a structure or union
user2121776
1

votes
2

answer
78

Views

Why is my grid not drawing?

I'm trying to setup a grid for path finding in a box2d environment. Is it my drawing method which is why none of the nodes and links between them are being drawn? here is my main class for drawing the world: @interface HelloWorldLayer() @end @implementation HelloWorldLayer +(CCScene *) scene { // 's...
Lewis
1

votes
1

answer
518

Views

Cocos2d - how to scale two CCNodes with respect to each other

I have two CCNodes in Cocos2d that I want to dynamically scale in sync with each other. Both CCNodes are background nodes. Visually one CCNode, NodeA, is above the other CCNode, NodeB in the y direction. But when I scale both nodes at the same time as in the code below: Edit #1 - Node B is part o...
James Testa
1

votes
2

answer
1.7k

Views

ccTouchesMoved works but ccTouchMoved does not

self.isTouchEnabled = YES; in init method ofcourse. -(void) ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint location = [touch locationInView:[touch view]]; location = [[CCDirector sharedDirector] convertToGL:location]; } -(void) ccTouchMoved...
V.D
1

votes
1

answer
852

Views

How to switch sprite between differents CCSpriteBatchNode in cocos2d

I'm making a game in cocos2d, I have a chicken as character that use a CCSprite. This chicken have multiple images doing different movements. There are so many images for the movements that I have to use multiple plist files for the sprite. My problem is that I can switch between the differents spr...
Tony
1

votes
2

answer
2.4k

Views

How to give a CCSprite an specified alpha channel?

I want to create a paint-pen in Cocos2D. and I have a png file which specify the alpha channel value of a image.(only one channel) I want to give the alpha value to a ccsprite's texture which is pure color. and make use of the ccsprite unit as pan.to draw on the screen. How can I do it in programmin...
sxingfeng
1

votes
1

answer
108

Views

CCSprite doesn't display on iPhone 4

I have a an app using cocos2D for a mini-game. When I push a button, I launch a cocos2D scene with the game. I try to load just a image in background (bg.png) in my cocos2D scene. I'm using sprites. It works on iPhone 5 and iPhone 4S (iOS 6), but it doesn't work on the iPhone 4. On the iPhone 4 I ha...
cmii
1

votes
2

answer
334

Views

making random objects with NSTimer in cocos2d

Hi i'm making a game with cocos2d.I want to create random objects with NSTimer. The objects are stored in an NSArray.I'm using the following way, but every time the timer initializes the same thing is happening. Just like if random wouldn't work. I'm weird. I would be happy if you could tell me what...
kommancs96
1

votes
2

answer
235

Views

cocos2d iPad crash when setting [_director displayStats:NO]

I just completed a quick 1st draft prototype of a cocos2d iPad app. I have not modified the CCTextureAtlas.m file. The app runs fine when I leave [director_ setDisplayStats:YES] in the AppDelegate, but if I remove that line or substitute [director_setDisplayStats:NO], it crashes in CCTextureAtlas.m...
Clay
1

votes
2

answer
1.3k

Views

How to rotate cocos2D game into landscape mode in iOS 6?

I have an iPhone 4S (running iOS 5.1) & an iPhone 5 (running iOS 6.1). I noticed that when i try to open the cocos2D game, on the iPhone 4S running 5.1, the game is able to open perfectly fine in landscape mode. However, when I try to open the same cocos2D game on my iPhone 5 running 6.1, the game...
Kofi
1

votes
1

answer
117

Views

How much memory can I use when preloading textures?

I am trying to decide if I should preload all of my textures on a loading screen in my game, but I don’t know how much memory I can use for this. I looked around the web and I found where someone said that you can preload all of your textures as long as it is 80MB or under. If this is correct does...
Stephen
1

votes
2

answer
748

Views

Moving Platforms? Cocos2d and Tiled

I'm trying to make some moving tiles from a Tiled map editor tmx file. I have the moving tiles in their own layer, and I just want to simply have them move up, and then when they reach a certain y, move back down, and etc. I have been looking around for a bit on a clear way of accomplishing this, bu...
JoeyMaru
1

votes
1

answer
510

Views

layer update does not get called in cocos2d-iphone

I'm having an issue with the HelloWorldLayer class' update: method not being called when building and running the applications on my iPad. Not really sure what the issue is as init: and accelerometer: didAccelerate: are called as expected. Here is the implementation of HelloWorldLayer: // Import the...
Gabor
1

votes
1

answer
722

Views

cocos2d landscape game present portrait viewcontroller

my game uses cocos2d landscape mode. when I need to present view controllers, they are also in landscape mode, for example, game center and store view controller. Store view controller works for ios6 and before (looks a bit weird since the content is still in portrait mode), but it crashes on ios7....
OMGPOP
1

votes
1

answer
88

Views

Display a CCSprite seven times

I am a beginner in Cocos2d and I wanted to display 7 coins in a horizontal pattern. So this is what I wrote in my main gameplay layer: In my init, I have this coins = [CCSprite spriteWithFile:@"coins.png"]; I made a method for the coin patterns I want it to be in (display seven times across) - (voi...
Shalin Shah
1

votes
1

answer
234

Views

CCDirector wrong window size on iPhone5

This is the first time i have this problem . -(void)onEnter { [super onEnter]; winSize = [[CCDirector sharedDirector] winSize]; NSLog(@"wins:%f",winSize.height); is returning 480 on iPhone5 simulator . Whats wrong here ?? its in onEnter ..
Curnelious
1

votes
1

answer
319

Views

How remove color of ccsprite?

I had applied color to a ccsprite. The sprite is initilize with an image of green color. After then i applied red color to it. Now how to remove the red color and bring it back to original image color? Suppose this is the original image Now when i apply red color to it, it is colored as red. My ques...
Jay Gajjar
1

votes
3

answer
770

Views

How to load animation in background in cocos2d?

I am currently developing one cocos2d game for iPad, in that game lot of animations is there. I have previously used zwoptex for creating spritesheet and adding animations in my project. In my game 10 Levels is there, and after each level completed one animation will play, the animation is differen...
banu
1

votes
1

answer
201

Views

Removed sprite still seems to exist – cocos2D

I'm making a little game with cocos2D where you can steer a ship with the accelerometer and shoot down things by tapping the screen. The things you shoot down are controlled by a CCMoveTo which moves them from top of the screen down to below 0. If the ship collides with one of the flying things they...
Wilhelm Michaelsen
1

votes
1

answer
1.5k

Views

File not Found when loading multipack spritesheet in Cocos2d

I'm attempting to use multipacking via TexturePacker to handle multiple animations for the same sprite. I added all my images in TexturePacker and published them, no problem. I've added them to the Resources folder in my project and I even see them in Finder. When I attempt to call this -(CCSpri...
SnareHanger
1

votes
1

answer
326

Views

Cocos2d: thread error when trying to add background music

Hello I am making a cocos2d side scroller. I am trying to add a background audio file. I am using SimpleAudioEngine. This is the code: [[SimpleAudioEngine sharedEngine]playBackgroundMusic:@"Soundtrack.mp3" loop:YES]; But when I run it it gives me a error. The line that it says is giving me the erro...
PoKoBros
1

votes
3

answer
1k

Views

Tell when a CCAction is done running

I want to be able to stop all actions when my animation sequence is done running, how would I do that? Right now i have: CCAnimation *spinAnim = [CCAnimation animationWithSpriteFrames:spinAnimFrames delay:0.1125f]; self.spinAction = [CCAnimate actionWithAnimation:spinAnim]; and then later: [self.cha...
user1569940
1

votes
1

answer
741

Views

Brake all joints in an object in box2d

I am developing a small app on the iPad where the user can drag object together. When the objects touch, I create a distance joint that stick the objects together. This is working fine. If the user touches the object again to drag it, I'd like to be able to move the object alone and not all the obje...
G A

View additional questions