Cocos2d Archives

CCSpawn action in Cocos2d

The CCSpawn action lets you run several actions at the same time. The duration of the CCSpawn action will be the duration of the longest sub-action.

Speed Actions in Cocos2d

The CCSpeed action modifies the duration of the inner action.

difference between @synthesize and @dynamic

@synthesize will generate getter and setter methods for your property. @dynamic just tells the compiler that the getter and setter methods are implemented not by the class itself but somewhere else (like the superclass)

Uses for @dynamic are e.g. with subclasses of NSManagedObject (CoreData) or when you want to create an outlet for a property defined by a superclass that was not defined as an outlet:

Super class:

Subclass:

Incoming search terms:

  • distinguish between synthasize & dynamic in ios

CallFuncN and CallFuncND Actions

There are two variations of CCCallFunc. They are CCCallFuncN and CCCallFuncND.

CCCallFuncN takes the node as an argument, and CCCallFuncND takes the node and a pointer to some data.

For example:

Incoming search terms:

  • cocos2d x callfuncn selector

3D actions in cocos2d

Action that has the ’3D’ suffix in their names, means that they produce a 3D visual effects by modifying the z-coordinate of the grid.

If you’re going to use any ’3D’ action, probably you will want to use the depth buffer. An easy way to do that is by calling:

// IMPORTANT: Call this function at the very beginning, before running your 1st scene
// Create a depth buffer of 24 bits
// These means that openGL z-order will be taken into account

And under some circumstances, you might also want to set an RGBA8888 pixel format. This will let you have effects with transparency

// IMPORTANT: Call this function at the very beginning, before running your 1st scene
// Use this pixel format to have transparent buffers

Incoming search terms:

  • grid 3d cocos

How to save an image in the file?

You can use this code to save an image in the file.

Converting GL Point to UITouch point in Cocos2D

It is possible to convert GL point to UITouch point in cocos2D using the following code :

Consider a GL point, glLocation.

// Now location will contain the UITouch point corresponding to GL point, glLocation.

Incoming search terms:

  • glpoint mac

Transition in cocos2d

So far, we have been replacing scenes like this:

Fortunately, cocos2d comes with a whole slew of cheesy transitions. We’ll find all the transitions listed in the Transitions.h file in the cocos2d folder.

The interesting thing about calling this method is that it returns an instance of TransitionScene, which extends Scene and contains the scene you passed into it. So you can use this method directly in the call to Director’s replaceScene, or any other scene changing method.

How to draw lines in cocos2d

To draw a line in cocos2d, you can use the following code :

 

(Write this function in your code. This function will be called automatically. You just need to put the values for x1,y1,x2 & y2.)

 

How to draw a simple rectangle in cocos2d…

 

Write this function in your code.This function will be called automatically.Change the value of the vertices to vary the size of the rectangle.

Incoming search terms:

  • cocos2d-x draw rectangle
  • cocos2d draw rectangle
  • cocos2d-x draw filled rectangle
  • cocos2d add rectangle
  • draw colored rectangle cocos2dx
  • draw filled rect cocos2d
  • draw rectanagles in cocos2d
  • draw rectangle cocos2d color
  • fill rectangle cocos2d iphone
  • how to draw a filled rectangle in cocos2d
Page 20 of 42« First...10...1819202122...3040...Last »