Tag Info

Hot answers tagged

10

I found the implementation description from the author of this effect: It surely was a lot of work to create the depth illusion in a 2D plane. The principle is very easy though: circles start in the middle of the screen with scale 0. Then the first circle of the tunnel starts scaling proportionally to the time elapsed (linear scaling doesn't work) ...


9

Sprite animation is pretty simple. You just create a CCAnimation node, add the images to loop, then create an action using CCAnimate::actionWithDuration(float, CCAnimation, bool) and make the sprite run it. Example: CCAnimation * anim = CCAnimation::animation(); // There are other several ways of storing + adding frames, // this is the most basic using ...


6

You don't speed up the engine, you speed up your units and their actions. For example, when you update an enemy, you usually do something like enemyDirection * enemySpeed * timePassed to get their new position. Now, if you want to double or halve the speed of gameplay, you just add this in as a factor: enemyDirection * enemySpeed * timePassed * ...


5

In new version of CoCos2dx (2.1.1) you can use (it's working) CCSpriteFrameCache* cache = CCSpriteFrameCache::sharedSpriteFrameCache(); cache->addSpriteFramesWithFile("numbers.plist","numbers.png"); CCSprite* sprite = CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("slice2_0_0.png")); ...


5

You can use CCTMXTiledMap: http://www.cocos2d-x.org/reference/native-cpp/da/d68/classcocos2d_1_1_c_c_t_m_x_tiled_map.html It supports isometric, hexagonal and orthogonal tiles.


4

It really depends on your art style. Does the game look fine scaled down halfway? Would making new, lower-res artwork push you over the current OTA download size? If so, then keep the larger graphics. There are not a lot of people with 3GSs and 3rd gen iPod touches out there (the only currently supported non-retina small devices), and with iOS 6 the 3rd ...


4

My second question is that my actual game scene uses bound camera and I perform scrolling on that camera but my other scene uses the normal camera. So in this situation what to do? how to use multiple camera for single engine? or how to reset available current camera? Our 3d game engine allows us to create as many render targets we wish. A render ...


4

You are probably updating the velocity twice, since this is usually done in the integration step itself. I expect you implemented the RK4 integration from http://gafferongames.com/game-physics/integration-basics/. The author defines Derivative.dv as the acceleration (derivative of velocity) and State.v as as the velocity In the evaluate function you can ...


4

Currently I draw into a texture (1280, 720) or adapted to the screen ratio. Then this texture is displayed upscaled.


4

I'll answer my question, but @akg is the answer that guided me. I've made the code in cocos2d-x, and I didn't used boundingBox() method. Hope this helps someone, :) I didn't found something like this in other site, so I hope not be doing something wrong... bool SceneGame::ccTouchBegan(CCTouch* touch, CCEvent* event) { CCPoint touchPoint = ...


4

Your actual view of the ball or playing field shouldn't really matter in this. First of all, you'd mostly want a constant/fixed horizontal velocity for the ball. You can add air resistance to this, but it wouldn't really change anything, as you'll just have to add it to the equation. Ignore the actual height of the shot for now. Having a target distance as ...


3

You could create a Bézier curve that matches a sine (read this article for an example). Creating a Bézier curve from a sine, just to feed into CCBezierTo seems like a very counter-intuitive way of doing things though. I would skip CCBezierTo entirely and update the position of your sprite yourself. You could do so in your update method or implement a ...


3

You need to add CocosDenshion, which is the audio library. Be sure the link is done correctly or copypaste it into your folder and use <> import just in case #include <SimpleAudioEngine.h> Once you have it correctly linked the functions used are quite trivial: CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("stuff.wav"); Be ...


3

You could use something that someone has already created. http://ak.net84.net/iphone/creating-a-repeating-backgroundinfinite-parallax-effect-in-cocos2d/ It looks like the developer who wrote that ran into some troubles using the out of the box object as well and as such he decided to write a custom solution and subsequently share it with the world! Good ...


3

You need to ask for the device's resolution, and then, set the viewport to fit it. I assume that you are using Cocos2d X, they call it Multi Resolution, hope this helps. Edit: This post from Jesús bosch may give extra information about the topic.


3

On the collision, simply reference the relative positions of the two objects. If the ball is above the block, it struck the top. You really only have to check the y coordinate if you're sure a collision is happening. Something like the following: Simply check to ensure the y coordinate of the circle is within a tolerance of the box half-height + the ...


3

Implement your own Point class. That's good design if UI Point is seperate from logic Point. //Point.h class Point { public: int x,y; }; Point different to cocos2d::Point. In Projectile class, you include and use it. //Projectile.h #include "Point.h" class Projectile { public: char* image; Point* position; }; Then render class, include the ...


3

ngoaho91 is basically hinting in the right direction but is not spelling it out explicitly, so I will try to make it more explicit. So you took the framework and started implementing the logic within the separate framework classes. The problem why you can't simply test the game logic in isolation, is because it is not isolated. You write that you ...


3

Without ever having implemented this... First you will have to control every step of the new gems on their way to their final place. Or in other words, move your sprites only on field on your grid and then calculate their next field. Now generate new gems and drop them into that column. On each step you check if the gem can fall further down. If not check ...


3

EDIT : Multi-resolution bug fixed. Here is my solution for you: First of all Let's sync some assumption: We have a layer ( Let's say MapLayer ) that includes game map ( Let's name it map) and other map-related objects, e.g. towers and enemies. I didn't use CCCamera. I tried to scale and move MapLayer instead. bottom-left and top-right position of map ...


2

If you don't want to use a .plist file and want to continue with the Ef Es's answer with the current version of cocos2d-x, just change some lines as below: CCSprite * sprite = CCSprite::create("bear1.png"); // NEW - create a sprite here CCAnimation * anim = CCAnimation::animation(); // There are other several ways of storing + adding frames, ...


2

The steps are as follows: Generate the project for Android using cocos2d-x template Add project to NVPack's Eclipse Fix make files, IDE configuration and whatnots Compile the libraries with Cygwin and build_native.sh script, they will be automatically added to the obj folder of the project Execute/debug like an Android application Those are the windows ...


2

I think you've got the right idea, but the execution is going to be immensely challenging. I'm presuming when you say 'in an SVG file' you mean that the shape is defined by one (or more — your sample figure has an internal hole!) stroke paths. Unfortunately, SVG paths can be remarkably complicated, with both quadratic and cubic Bezier curves and ...


2

Just use Bezier, giving 3 points in concave section, and another 3 in convex section, its easier than give all points to do a perfect sine, and the trajectory is the same.


2

you can't set a callback function for CCLabelTTF or any other Label class, yet there is CCMenuItemLabel you can use. you first need to create an instance of CCMenu class. then you need to allocate CCMenuItemLabel instance, using CCMenuItem::initWithLabel (CCNode *label, CCObject *target, SEL_MenuHandler selector). just check how helloworld sample handled ...


2

It's called 2D skeletal animation. Essentially you're animating a skeleton that has sprites for the body parts placed on top of it. This allows you to reuse animations for different characters and characters can have multiple sets of armor, weapons, etc. There are a number of questions on the site already about it: Tools for 2D skeletal animation How ...


2

I have this code working in cocos2dx 2.0.3, also make sure that you've added the plist and png file to your project, sometimes visual studio can be a bit funny about resources. CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("AnimBear.plist" ); CCSpriteBatchNode *spreetsheet = CCSpriteBatchNode::create("AnimBear.png"); ...


2

I found out the problem! :) In "credits.js" you need to change: onEnter:function() { }, onExit: function() { }, to onEnter:function() { this._super(); }, onExit: function() { this._super(); }, Hope this works for you! -Edit- The reason actions were not running is because 1) the engine was not being notified of any of the objects ...


2

I found my solution by creating subclass of PhysicsConnector. public class CustomPhysicsConnector extends PhysicsConnector { private float flagDisplacement; public CustomPhysicsConnector(IShape pShape, Body pBody, boolean pUdatePosition, boolean pUpdateRotation, float flagDisplacement) { ...


2

It depends what you mean by tile-based. Most 2D games that involve a level that you view from the top-down are tile based. In this way different tiles usually have different properties, and pathfinding such as A* is easy to implement. A lot of level editors use a tile-based sprite-sheet to define all of the aspects of a level, but then use them in a tiled ...



Only top voted, non community-wiki answers of a minimum length are eligible