cocos2d-iphone

Detect when UIGestureRecognizer is up, down, left and right Cocos2d

岁酱吖の 提交于 2019-12-17 09:32:52
问题 I have a CCSprite that I want to move around using gestures. Problem is I'm completely new to Cocos2D. I want my sprite to perform one action when the gesture is up, another one when gesture is down, another action when gesture is right and same thing for left. Can someone point me in the right direction? Thanks! 回答1: Apparently each UISwipeGestureRecognizer can only detect the swipe in the given direction. Even though the direction flags could be OR'ed together the UISwipeGestureRecognizer

How to add CCSprite over UIView

旧巷老猫 提交于 2019-12-14 03:52:22
问题 In my cocos2d application, I have a UIView that I am displaying on my screen by adding a subview to [[CCDirector sharedDirector] openGLView] , but I am wondering if there is someway to display a CCSprite above this view, since I have to do lots of interactions and animations with those CCObjects. Please help. Thanks in advance... 回答1: Of course you can't add CCSprite on UIView. CCSprite is from Cocos2d library class and UIView is UIKit class. If you want add UIView over game view then you

Objective C iPad Animation with large images - What method to use?

北城以北 提交于 2019-12-14 03:49:20
问题 I'm trying to build a weather application on the iPad but it seems that I need some help in animation. Say I'm animating a Radar, so the radar source files have 10 gif/jpeg pictures in 900x700 pixel size. I've tried the UIImage animation technique using the tutorial here: http://www.icodeblog.com/2009/07/24/iphone-programming-tutorial-animating-a-game-sprite/ but it seems that loading 10 images that big is too much for the iPad to handle and its crashing due to memory warnings. I'm

Unable to instantiate the UIApplication subclass instance

久未见 提交于 2019-12-14 03:17:34
问题 i'm building a SpriteBuilder project and getting the error of: " * Assertion failure in int UIApplicationMain(int, char **, NSString *, NSString *)(), /SourceCache/UIKit_Sim/UIKit-2903.23/UIApplication.m:2380 Unable to instantiate the UIApplication subclass instance. No class named NSApplication is loaded." For the main.m code of: #import <UIKit/UIKit.h> int main(int argc, char *argv[]) { @autoreleasepool { int retVal = UIApplicationMain(argc, argv, nil, @"AppController"); return retVal; } }

CCCallBlockN's alternative in Cocos2d v3.0

时光总嘲笑我的痴心妄想 提交于 2019-12-14 03:12:56
问题 What's CCCallBlockN alternative for Cocos2d 3.0 ? Here is my Cocos2d 2.0 Code: id calBlock = [CCCallBlockN actionWithBlock:^(CCNode *node){ node.position = orign; }]; 回答1: The CCCallBlockN and CCCallBlockND variants have always been superfluous since blocks can reference objects in the local scope: id someData = (some data however created or obtained); CCNode* someNode = (some node however created or obtained); id callBlock = [CCActionCallBlock actionWithBlock:^{ someNode.position = origin;

Playing audio in cocos2d v3

六眼飞鱼酱① 提交于 2019-12-14 03:12:26
问题 I am trying to get background music playing and looping as well as one-shot sounds every now and again, e.g. level up etc. I have found many tutorials on this that are using SimpleAudioEngine, but when I import SimpleAudioEngine.h the compiler is stating "SimpleAudioEngine.h file not found" I am using SpriteBuilder and cocos2d v3. Does anyone know where I can get this class from? Thanks 回答1: [[OALSimpleAudio sharedInstance] playBg:@"bakground.caf" loop:YES]; 来源: https://stackoverflow.com

How to convert a 2D image to 3D in iphone app [closed]

纵饮孤独 提交于 2019-12-13 23:13:43
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 6 years ago . Input: 2D image Output: 3D image Platform: IOS I need to convert a 2D image into 3D in my ios application.How to do this in my ios application? What are the frameworks I need to use? Will OpenGL-es helps in this?

Play interstitial ad every 3rd game

让人想犯罪 __ 提交于 2019-12-13 21:44:09
问题 I'm using the HeyZap mediation SDK. I have all the mediation set up perfectly fine, but I would like for the interstitial ad to show every 3rd game. I've tried some solutions here on Stack Overflow but they apply to AdMob. Right now, I have: -(void) GameOver { .... [HZInterstitialAd show]; } How do I achieve this? 回答1: keep a counter of the number of games played and then only show it if static int count = 0; -(void) GameOver { if(count != 0 && count % 3 == 0) [HZInterstitialAd show]; count++

Removing MANY CCSprites

隐身守侯 提交于 2019-12-13 21:09:18
问题 Hey guys and girls. I have a method that creates rain particles, tiny images, of CCSprite class type. Everything is working well, when the clouds rain, they rain many particles of CCSprites until they leave the vertical winsize space.. Once they do leave the vertical winsize space, the iphone simulator begins to lag as it removes each rain CCSprite. I think the problem is that their are so many CCsprites to remove, not the actual demand of having them in the memory. My method to remove

Most Efficient way to deal with multiple CCSprites?

别等时光非礼了梦想. 提交于 2019-12-13 21:05:33
问题 I have four different types of objects within my environment(box2d), each type of object having multiple instances of itself, and would like to find the most efficient way to deal with adding and manipulating all the CCSprites. The sprites are all from different files, so would it be best to create each sprite and add it to a data structure (NSMutableArray) or would I use a CCSpriteBatchNode even though each CCSprite file is different (for each type of object)? Thanks. @interface LevelScene :