Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am developing game like galaxian and using cocos2d with box2d .I don't have idea how to create enemies like galaxian game enemies and how do they fly over the screen.

Could you please help me how to do this ?

I have created the enemies but when i look at the game enemies fly how they are flying ?

share|improve this question
What movement are you trying to recreate? What have you tried? – Ricket Oct 7 '12 at 7:17
I have created the enemies but when i look at the game enemies fly how they are flying ? – jubin Oct 7 '12 at 7:40
@jubin their X and Y coordinates change. – Markus von Broady Oct 7 '12 at 7:44
To make them fly curves take a loot at Bézier curves: – bryan226 Oct 7 '12 at 10:22
@jubin "How do I make them fly?" is really vague and broad - you just change their positions, after all! If you're asking for a specific way to make them fly, like the ones that fly in a curve, you should specify that. – doppelgreener Oct 7 '12 at 17:01

Initialise and assign a movement function to each enemy as a function of time for e.g.

x(t) = 5 * sin(t)
y(t) = t * 0.2

final position = Point(x(t), y(t))

when they start flying, plug in the game elasped time since start of flight into x(t) and y(t) to give you the new X and Y coordinate of the enemy.

A boss movement function could be e.g.

x(t) = 10 * sin(0.2 * t)
y(t) = cos(0.2 * t)

NOTE: depending on the coordinate system of your game, you may need negative functions.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.