cocos2d-iphone

Monsters/Enemies on Platforms(like on Doodlejump)Cocos2d

强颜欢笑 提交于 2019-12-13 04:24:51
问题 I'm new here so i hope you can help me. I am following a tutorial on making simple cocos2d game Ray Wenderlich's Tutorial I implemented it on another game a jumping one like doodle jump. in the said tutorial the monsters/targets are moving freely coming from the right to the left side of the screen. when i implement it on my app the monsters are like flying from left to right. What if i want the monsters to stand on the platforms just like the one on doodle jump? what particular things will i

Countdown in Cocos2d

蓝咒 提交于 2019-12-13 04:23:36
问题 I am trying to think through how to implement a countdown on a stamina level. For example, maximum 100% and over time it decreases. I don't need to know how to display it but the technology behind it to get it working and where to look. This countdown would keep on going down when the application is closed. I was looking at NSUserDefaults as a means to do this. Is this correct? Similar to the top bar as shown below: 回答1: You can save latest refueled stamina value in NSUserDefaults or in

Cocos2d - Default iPhone5 support with -wide / -widehd not working

我与影子孤独终老i 提交于 2019-12-13 04:21:40
问题 I believe now Cocos2D 2.1 and above Support iPhone5 with image extension -widehd.png I used same but not working in my game. Just searched in cocos2d and found these in CCFileUtils.h - iPhone: "" - iPhone HD: "-hd" - iPhone5 : "-wide" - iPhone5 HD: "-widehd" - iPad: "-ipad" - iPad HD: "-ipadhd" - Mac: "" - Mac HD: "-machd" This indicates now by default cocos2d support iPhone5. Why not working for me? 回答1: CCFileUtils has the option to search resources in folders without using Suffix, and it's

Loading Data Files on iPhone?

本秂侑毒 提交于 2019-12-13 04:18:13
问题 What is the best way to load static data files containing game level maps on the iPhone? I have seen some use XML files, but that seems like overkill in my situation as the data files merely determine the layout of the game's level, ie where obstructions will go. Also, what project directory should they be stored in? Thanks in advance! 回答1: If your files are really static, then you'll want to store them in your application bundle (just add them to your project; Xcode will copy them to the

Improper iPhone orientation?

99封情书 提交于 2019-12-13 04:17:26
问题 I can't figure out why this isn't working. I'm writing a game that involves scrolling rows/columns of blocks around the screen. I have my orientation limited strictly to Portrait, but it doesn't behave as so. When I call the method below, it is handed the velocity from the pan. Using logs I was able to see that holding my device upside-down and panning around acts as if my orientation supports Portrait. How can I -completely- turn off anything but Portrait? Here's some code to help explain

Cocos2d: Is it ok to have a pointer to a parent's class pointer?

Deadly 提交于 2019-12-13 03:52:16
问题 Silly question. Cocos2d is build around the parent-child hierarchy. I was wondering if it is ok to have a parent class (e.g. GameScene) and initialize a child class (e.g. SpriteHandler) with a pointer to a member of the parent class (e.g. CCSpriteBatchNode*). I am trying to do this to optimize the number of CCSpriteBatchNodes. Here is a code snippet of my main class (GameScene style). #import <Foundation/Foundation.h> #import "cocos2d.h" enum ShooterSceneLayerTags { HudLayerTag = 0, };

Sprite disappears suddenly Cocos2d

亡梦爱人 提交于 2019-12-13 03:21:38
问题 i have this game like doodlejump i inserted some monsters and bullets on the player the player fires a bullet and deletes the target i inserted a nslog to both so i know if the bullet fires and the target shows all is working smooth in the simulator ios 4.0 but when everytime i install it on the device the bullet and the target seems to be not appearing( yes only those two the game is still running smooth) but everytime i check the console i can see the nslog of the bullet and target i tried

Game Objects setup in cocos2d + box2d

时间秒杀一切 提交于 2019-12-13 03:04:58
问题 I am having a design issue, this may be due to the fact that i don't fully understand cocos2d and box2d yet. I want to create game objects that have a CCSprite(image data) and a b2Body(physics), Would i be right to make an encapsulating object that contains both? if i did this this would enable me to make changes to the CCSprite OR as i have seen in the example code the b2Body has a userData variable which the sprite is set as. Then with this method i would only need to have a single pointer

how to actually pause a cocos2d scheduled selector?

感情迁移 提交于 2019-12-13 02:59:31
问题 I know there is probably thousands of people who asked this before. But my question is quite a bit different. I'm wondering if there is an actual way to pause a scheduled selector not just unschedule it. I need to know this because i have a selector being called every 50 seconds. if i were to unschedule that selector with 2 seconds left, then reschedule it, then the function would take 98 seconds to call the function. 回答1: You can do this to pause all selectors for a node (the target, in this

Bodies connected by a joint must be added to the same CCPhysicsNode, however two bodies are under the same CCPhysicsNode but

家住魔仙堡 提交于 2019-12-13 02:47:31
问题 I am making application by this tutorial. https://www.makegameswith.us/tutorials/getting-started-with-spritebuilder/spritebuilder-physics/ I made jointnode directly in code like this _mouseJoint = [CCPhysicsJoint connectedSpringJointWithBodyA:_mouseJointNode.physicsBody bodyB:_catapultArm.physicsBody anchorA:ccp(0, 0) anchorB:ccp(34, 138) restLength:0.f stiffness:3000.f damping:150.f]; but even though surely two nodes are under the same CCPhysicNode, it shows this error Bodies connected by a