cocos2d-iphone

Swift Cocos2d3.x CCSprite applyImpulse not giving proper jump

坚强是说给别人听的谎言 提交于 2019-12-25 06:56:23
问题 I am using Cocos2d3.x with SpriteBuilder in Swift language. I want to make some animation like bouncing ball on Polls as seen in this GIF: https://www.dropbox.com/s/43vwlbjoazaxe7u/jumpyBall_15_jul_15.gif?dl=0 If you have noticed in the GIF file, each second jump is half of the previous jump. So, it seems pattern of 1,0.5,1,0.5,1,0.5,... Following are my settings: Polls: Physics Enabled Density: 1.0 Static Body Collision Type: Platform Circle: Physics Enabled Density: 1.0 Dynamic Body

Removing Sprites from Array on physicscollision

偶尔善良 提交于 2019-12-25 06:04:07
问题 - (BOOL)ccPhysicsCollisionBegin:(CCPhysicsCollisionPair *)pair monsterCollision: (CCNode *)monster projectileCollision:(CCNode *)projectile { for (CCSprite *spr in spriteArray) { if (_monster1.lives == 0) { NSMutableArray *spritesToRemove = [[NSMutableArray alloc] init]; // Remove the sprite from its parent here. [spr removeFromParent]; // However, leave the "spr" in ssprites array - just "mark" it for deletion. [spritesToRemove addObject:spr]; if ([spritesToRemove count]> 0) { [spriteArray

Removing Sprites from Array on physicscollision

百般思念 提交于 2019-12-25 06:02:19
问题 - (BOOL)ccPhysicsCollisionBegin:(CCPhysicsCollisionPair *)pair monsterCollision: (CCNode *)monster projectileCollision:(CCNode *)projectile { for (CCSprite *spr in spriteArray) { if (_monster1.lives == 0) { NSMutableArray *spritesToRemove = [[NSMutableArray alloc] init]; // Remove the sprite from its parent here. [spr removeFromParent]; // However, leave the "spr" in ssprites array - just "mark" it for deletion. [spritesToRemove addObject:spr]; if ([spritesToRemove count]> 0) { [spriteArray

A sprite bounding box shows wrong position after moving the layer

二次信任 提交于 2019-12-25 05:38:24
问题 I have just started to learn some cocos2d and this issue had bothered me for quite a while. Basically what i am trying to do is to move a sprite in a layer by checking whether the touch landed on the sprite bounding box using ccTouchBegan and ccTouchMoved . Everything worked until I moved the layer, which include many other sprite and is also lager than the screen size. After I moved the layer the sprite's bounding box is at a different position as where the sprite image shows. Had anyone

Cocos2D: Get layer's position in scene from another class

人走茶凉 提交于 2019-12-25 05:22:30
问题 I'm trying to retrieve the current position of the layer added as a child in a scene while a scene transition is occurring. The transition is an edited Cocos2D transition that slides the layer off the screen while a new one appears. I created my own implementation inside CCActionEase with an update method: #import "JoinedMapsScene.h" #import "JoinedMapsLayer.h" @implementation CCEaseInWithPercentMult -(void) update: (ccTime) t { [other update: powf(t,rate)]; CCScene * scene = [[CCDirector

new in using XCode Instruments to interpret memory warning for iPhone development, guidance needed

亡梦爱人 提交于 2019-12-25 05:01:30
问题 I am working on an iPhone game which receives memory warning that I am not experienced enough to interpret. I have been watching some iTunesU tutorial but I am still not very good at this.. I have received various memory leaks whilst running my game and I wanted to understand how to interpret the stack trace show in Instruments properly. I attach a screenshot of the ObjectAllocation instrument output . Even when I zoom filter I don't manage to filter the data in the ObjectSummary . The peaks

runAction do not works for sprites coming from CCSpriteBatchNode

拟墨画扇 提交于 2019-12-25 04:57:46
问题 I am using Cocos2d 2.1rc0. I have this project that was working perfectly when I was not using CCSpriteBatchNode. Then I decided to use batch nodes to reduce draw calls and my problems started. A lot of stuff is not working well. reorderChild is one. Another one is runAction and without runAction Cocos is useless. This is an example of a method that works without batchNodes and do not work with it. // move/rotate all objects for (int i=0; i<[allObjects count]; i++) { Card *object =

Move CCSprite around another CCSprite Circle Shape

送分小仙女□ 提交于 2019-12-25 04:19:30
问题 What I am trying to accomplish is this: We have CCSprite Circle A and CCSprite Circle B. Move Circle B around Circle A. I already tried to create a CCNode and attach the circle B to it. In this case it works perfectly but the position is constant also. I need to move the circle around A and update the position. I will have more objects on the screen and I will check if B intersect some other objects, but for that case I need to update the position while rotating. Much appreciate your help

onTouch Events not being called, when sprite moves off initial part of map?

我们两清 提交于 2019-12-25 04:19:18
问题 It appears no onTouch events are being called (put NSLog statements in to confirm) when my player is moved above or to the right of my map. Map is big enough, and you can still see the map slightly when I get to the top or right, as the layer shifts as intended, but when clicking any further then what's initially loaded on screen, no touch events are being fired and char is stuck. Any ideas? - (void)setCenterOfScreen:(CGPoint) position { CGSize screenSize = [[CCDirector sharedDirector]

sprite sheet not working for retina display

痴心易碎 提交于 2019-12-25 04:12:27
问题 I have create a sprite sheet for non retina display and its working fine on simulator.. I have used the code -(Void)addSprites{ [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"image.plist"]; CCSpriteBatchNode *spriteSheet = [CCSpriteBatchNode batchNodeWithFile:@"image.png"]; [self addChild:spriteSheet]; // Load up the frames of our animation NSMutableArray *walkAnimFrames = [NSMutableArray array]; for(int i = 1; i < 5; i++) { [walkAnimFrames addObject:[