Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Sprite position in terms of tiles


microspace
 Share

Recommended Posts

Is there a way to determine sprite position in terms of tiles, faster than in the example: 

 update: function () {
      var cposx = Math.floor(player.x / TileSize);
      var cposy = Math.floor(player.y / TileSize);
}

I dont want to load too much calculations inside update function. Maybe there is asynchronous way to do this or maybe there is built-in function to od this.

Link to comment
Share on other sites

Is it necessary to calculate position every frame? Maybe you could update players position only when he is actually moving, or even only once after the move ends. Besides, I do not think that such simple calculations could slow down game in any noticeable way.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...