cocos2d-iphone

Suitability of using Core Animation on iOS vs using Cocos2D and OpenGL ES?

做~自己de王妃 提交于 2019-12-24 07:59:28
问题 I finished a breakout game tutorial in a book, but the ball, which is a 20x20 pixel image, was skipping frames and not moving very smoothly. That is the case on the Simulator as well as on an iPhone 4S (the real thing). The code wasn't using NSTimer (which may be slower), but was using CADisplayLink and UIImageView setFrame to do the animation. Is Core Animation on iOS not very suitable for development animation type of games? Say if it is a game of Invaders (Space Invaders) Breakout (as a

Opposite of glscissor in Cocos2D?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-24 06:49:59
问题 I found a class called ClippingNode that I can use on sprites to only display a specified rectangular area: https://github.com/njt1982/ClippingNode One problem is that I need to do exactly the opposite, meaning I want the inverse of that. I want everything outside of the specified rectangle to be displayed, and everything inside to be taken out. In my test I'm using a position of a sprite, which will update frame, so that will need to happen to meaning that new clipping rect will be defined.

Incremenent NSnumber every 5 seconds - Cocos2d

寵の児 提交于 2019-12-24 05:55:04
问题 I am trying to increment a NSNumber every 5 seconds by 1 in Cocos2d but for some reason it isn't working (probably obvious mistake). I am using the update method but I think this may be the wrong place. Currently it is only adding +1 once. I need it to do this every 5 seconds constantly: -(void) update: (CCTime) delta { // Save a string: NSNumber *anInt = [NSNumber numberWithInt:500]; NSNumber *bNumber = [NSNumber numberWithInt:[anInt intValue] + 1]; NSLog(@"Update Number%@",bNumber); } 回答1:

What is the best way to draw a large number of lines using openGL and cocos2D?

怎甘沉沦 提交于 2019-12-24 05:32:57
问题 I have a series of 2d vertices that represent the lines used to draw a grid. There are about 900 line segments to draw (the grid uses spring physics to distort, which is why I don't just draw a single line for each row and col). cocos2D has a ccDrawLine function built in, which draws fine, but I think this may be inefficient since it is calling glDrawArrays for each line segment. How do you efficiently draw a large number of line segments? As a bonus, please recommend a source of good 2D

How to remove black screen between scenes in CCTransitionPageTurn?

梦想与她 提交于 2019-12-24 04:18:16
问题 I need to use CCTransitionPageTurn in my app between scenes. When i run this transition, my running scene looks nice - it turns like page. but at the background i see black screen(during page turn animation), that is replaced later by new scene. And i want to see new scene in the background(during animation), when i start this transition. Can anybody help me? 回答1: Oh, i found out the answer. All works as it should, after i commented out this line //director.projection =

How to add seperate iPad and iPhone images in spritebuilder- Cocos2d 3.2

只谈情不闲聊 提交于 2019-12-24 03:07:04
问题 I love that Spritebuilder takes the retina iPad image and automatically makes the scaled down iPhone images. I make one image (ipad retina), And spritebuilder makes the iPhone ones automatically: But for certain buttons/sprites, I wanted to make both the iPad and iPhone images myself. How do I add custom iPhone AND iPad versions for an image that can be used in the Spritebuilder UI? Eg. Use one image for iPad (retina), But use another one for iPhone. Also, how do I add something like an

Circle shape clipping with opengl-es in cocos2d

雨燕双飞 提交于 2019-12-24 01:18:00
问题 I'm trying to make a circle shape clipping on a CCSprite in cocos2d, after searching a lot, i tried the open gl glScissor method, i achieve an squared clipping over my sprite. But, i need to make it a circle, and it seems to be impossible to do with the glScissor. I kept trying and I found something about gl stencil, but I haven't found a how to on this and I'm not familiar with opengl. Also I heard something about calling multiple times to the glScissor wo you can achieve a custom shape but

Pixel-Perfect collision for ignoring transparent areas of sprites

大憨熊 提交于 2019-12-24 00:45:28
问题 I've recently come across Pixel-Perfect collision between two sprites from this link: http://www.cocos2d-iphone.org/forum/topic/18522. I'm just wondering if its possible to implement this using 1 sprite and CGPoint(touch). If this is, can anybody explain how to implement it that way? Thank you 来源: https://stackoverflow.com/questions/14699400/pixel-perfect-collision-for-ignoring-transparent-areas-of-sprites

Accessing an Object from Class type(+) method in iPhone & Cocos2d?

大兔子大兔子 提交于 2019-12-23 19:25:25
问题 i have a class method in which i am creating and returning the class object. But i want to access certain properties of that object in the same class. Being a class method i cannot declare the variable in .h file and later access it in other methods. Following is the code How can i access the values of backsprite or hudlayer object in the instance method below?? // class 1 +(id)HUDWithBackgroundSprite:(NSString *)spriteName withRect:(CGRect)rect atPoistion:(HUDPosition)pos { HUDlayer *hud = [

Cocos2d EXC_BAD_ACCESS

怎甘沉沦 提交于 2019-12-23 16:34:18
问题 I am new to cocos2d and suddenly got this EXC_BAD_ACCESS, I made a new winning menu and i got the error I think the error is because i called a released object, but i dont release anything? My Debug Console had no error, which is strange here is my Level_1.m // // Level_1.m // iPadGame // // Created by My Name on 1/25/12. // Copyright 2012 __MyCompanyName__. All rights reserved. // #import "Level_1.h" #import "HelloWorldLayer.h" CCSprite *player; CCSprite *enemy; CCSprite *enemy2; CCSprite