cocos2d-iphone

How can I pass multiple objects to a delayed method?

烂漫一生 提交于 2019-12-25 01:55:50
问题 How can I pass -(void)explosionFromPoint:(CGPoint)explosionPoint withSprite:(CCSprite*)sprite; in a [self performSelector:@selector(//Right here) withObject:nil afterDelay:3]; ? You cant put the whole selector inside the @selector() , and withObject first of all only allows one object to be passed over, and neither do I understand how to use it. How can I pass a method with objects after a delay? I also tried a workaround where I call [self performSelector:@selector(waitExplosion) withObject

Get the alpha value at the touched point on a sprite in Cocos2D

只谈情不闲聊 提交于 2019-12-25 01:25:09
问题 I am doing an application where I need to get the alpha value at the touched position on a sprite. Thanks in Advance 回答1: I use this code to retrieve the alpha value: GLubyte pColor[4]; CGPoint newpoint = (...your screen point in GL coordinates); glReadPixels(newpoint.x,newpoint.y,1,1,GL_RGBA,GL_UNSIGNED_BYTE,&pColor[3]); pColor[3] then contains your alpha value. You probably will have to combine this with code to check whether your position is inside the sprite's bounding box. Make sure you

cocos2D deallocing CCScheduler

£可爱£侵袭症+ 提交于 2019-12-25 00:18:43
问题 This problem started happening when I subclassed CCSprite (Entity) to recieve touch input. When I'm going away from the main scene by pushing to another, I make all Entities remove their delegation from the shared CCTouchDispatcher (ie onExit()). And then reactivate when the main scene returns (onEnterTransistionFinished()). Half of the times this works fine. However, the other times this happens: cocos2d: deallocing <CCScheduler: 0x2323a0> Which I find rather strange. Is it even plausible

What is the better way to get mouse hold time?

淺唱寂寞╮ 提交于 2019-12-24 22:42:46
问题 I'm trying to count the time that player is holding the mouse button down. I tried this but it didn't works: var Game = cc.Layer.extend({ count: false, countTimer: null, init: function () { var selfPointer = this; this.canvas.addEventListener('mousedown', function(evt) { selfPointer.count = true; selfPointer.countTimer = window.setTimeout(selfPointer.Count(), 1); }); this.canvas.addEventListener('mouseup', function(evt) { selfPointer.count= false; window.clearTimeout(selfPointer.countTimer);

drag on CCLayer sometimes working

ⅰ亾dé卋堺 提交于 2019-12-24 20:17:57
问题 Im having trouble to get the touches to work on a Custom class -(void) ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { NSSet *allTouch = [event allTouches]; UITouch *touch = [[allTouch allObjects]objectAtIndex:0]; CGPoint location = [touch locationInView:[touch view]]; location = [[CCDirector sharedDirector]convertToGL:location]; DragItems = [[NSMutableArray alloc]initWithObjects: Bubble01, Bubble02, Bubble03, Bubble04, Bubble05, Bubble06, nil]; for(int i = 0; i < [DragItems

Syncing sounds with frames inside CCAnimation for cocos2d 2.x*

不羁岁月 提交于 2019-12-24 20:06:10
问题 How would I sync sound effects with an animation (CCAnimation) NSMutableArray* animationframes = [NSMutableArray array]; [animationframes addObject:[[[CCAnimationFrame alloc] initWithSpriteFrame:[TitleLayer spriteframeForFile:@"title_startanime01.png"] delayUnits:1 userInfo:nil] autorelease]]; [animationframes addObject:[[[CCAnimationFrame alloc] initWithSpriteFrame:[TitleLayer spriteframeForFile:@"title_startanime02.png"] delayUnits:1 userInfo:nil] autorelease]]; [animationframes addObject:[

COCOS2D: how to animate falling bricks into a grid

≯℡__Kan透↙ 提交于 2019-12-24 19:28:16
问题 I'm trying in the beginning of the game to animate 41 bricks to fall into a grid that is 6x7 from the top of the screen but so far I've just been able to make the bricks to fall down at the same position. If I remove the animation part then all bricks appear on the grid. The bricks should fall down with a millisecond or two after the previous brick to create the effect of steps. I know that the position is the issue but I don't know how to fix it. -(void)AnimateBricksFalling { self.allowTouch

'Receiver type “CCParticleBatchNode” for class message is a forward declaration'

橙三吉。 提交于 2019-12-24 19:14:04
问题 The title speaks for itself. I installed cocos2d 1.1 by downloading the files from github, removing the cocos2d project inside my project and re-adding it. I have a '@class CCParticleBatchNode' in my header file and #import "cocos2d.h" both in my prefix and in the relevant implementation file. When i browse to the location CCParticleBatchNode should be, it is there. So, does someone know what the problem might be? :) Edit: Here's some code. #import "PrecipicationLayer.h" #import "cocos2d.h"

how to detect touch in a circle

喜欢而已 提交于 2019-12-24 19:09:08
问题 I really assistance. Im a little confused. i have a circle sprite, and this code -(void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { CGSize winSize =[[CCDirector sharedDirector] winSize]; UITouch* myTouch = [touches anyObject]; CGPoint location = [myTouch locationInView: [myTouch view]]; location = [[CCDirector sharedDirector]convertToGL:location]; CCSprite *circleSprite = (CCSprite*)[self getChildByTag:30]; CGRect correctColorSprite1 = [circleSprite boundingBox]; if

My GKMatch has no players…?

大憨熊 提交于 2019-12-24 19:03:24
问题 I successfully made a matchmaking screen appear. I run my game in my iPhone and also in the simulator. In both cases I log in with a different Game Center account. I go to the matchmaking screen in both games. I press "play now". Both games begin looking for a match. Finally, both games find a match and call the function below: - (void)matchmakerViewController:(GKMatchmakerViewController *)viewController didFindMatch:(GKMatch *)match { self.myMatch = match; NSLog(@"%d",[[self.myMatch