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

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 background ( Let's name it map) and its content( 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 ...


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

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.


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

Lua is a pretty well developed scripting engine that is flexible and easy to integrate to your games, and is already supported in many game engines, for instance: 2D Agen (Lua; Windows) Blitwizard (Lua; Windows, Linux, Mac) Corona (Lua; Windows, Mac; iOS/Android) EGSL (Pascal/Lua; Windows, Linux, Mac, Haiku) Grail Adventure Game Engine (C++/Lua; Windows, ...


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

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 ...


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 ...


4

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 ...


4

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 ...


4

It's quite simple actually: cocos2d javascript is the join up of cocos2d-x's JSB and cocos2d html5. It's just a name given to that mix up. JSB is a set of Javascript native function overwrites that, when interpreted by the necessary scripts, are converted to their native correspondents. And these native functions are interpreted by the compiler, resulting ...


4

There is no option about dp in cocos2dx and in fact we don't need it. But cocos2D-x 2.x and 3.x have very easy solution for multi-resolution problem ( either iDevices or Android devices) As you saw in Multi-resolution support document. In fact you just need to set your DesignResolution and then just imagine your target device will has this resolution. If ...


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 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

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 ...


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

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

There are a number of things to ask, but if you understand the basics you should be able to not just determine the speed your sprite is moving but dictate it. Unless you are overtaxing the processor, or you schedule a routine to "update" less often, the game "loop" is going to execute 60 times per second. Assuming the routine that moves your sprite is ...


3

Edit: Here is some math Circ = radius * 2 * 3.14 dx = ball_speed * dt to get deltaAngle a lets solve a/dx=(2*3.14)/circ a = (2*3.14*dx)/circ sobstituting circ = radius * 2 * 3.14 we get a = dx/radius so delta angle belongs to speed , dt and radius putting this stuff into love2d we get function ent:update(dt) local dx = ent.speed*dt ...


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

Well, it depends on your artists and how they are designing, if you use Adobe Illustrator, which is vector based, that means you can scale to whatever size you need. My process is to draw the image I want out on paper, scan it in, make a version in of the drawing in Adobe Illustrator (using the drawing as a template), then rasterize in Adobe Photoshop and ...


2

you should use two sets of graphics, this might help you reduce memory usage too as its already built into the framework of cocos2d. You need to add a suffix on your images, apple uses the ”@2x” suffix, but cocos2d doesn't use that extension because of some incompatibilities. Instead, cocos2d has its own suffix: ”-hd”. You'll need to enable retina mode ...



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