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 trying to implement "Snake" using crafty.js but I can't seem to get the snake entity to move just once in a second. How do I do this?

share|improve this question
up vote 0 down vote accepted

You could use the timeout method from Crafty core functions.

First argument is the function to be executed, second argument is the time in miliseconds

  init: ...
  move: function() {
      //code for movement
      this.timeout(move, 1000);

or you can pass an anonymus function as argument

this.timeout(function() {
//code code coode
}, 1000);


Sorry if i my English is bad

share|improve this answer
I must have missed this in the documentation. Thank you for pointing it out. – gnerkus Apr 17 '13 at 0:38

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.