Benjans Posted January 16, 2014 Share Posted January 16, 2014 Hi everyone, Just begining with Phaser, i love the phylosophy and how it works For my game, I'm drawing a big tilemap (100 x 100), adding static objects with no problems.Then I want to add moving objects, so I create a group and add sprites to the group, with a simple velocity.And... it doesn't work very well. It seems like each time a new sprite is attached to the group, the animation stops, then restart, so it's not smooth at all Maybe I'm doing something wrong, but I don't think so (i'm properly destroying objects).I tried with Tweens too, but the result is the same. You can check it here : http://benjans.byethost3.com/city/ Thank you for your help guys! Link to comment Share on other sites More sharing options...
Pixelguy Posted January 16, 2014 Share Posted January 16, 2014 Runs smooth for me.. Link to comment Share on other sites More sharing options...
Benjans Posted January 16, 2014 Author Share Posted January 16, 2014 You don't see a small slowdown when we add a sprite?It's not very important currently, but the map is almost empty... I don't want the game to lag like death later Link to comment Share on other sites More sharing options...
Pixelguy Posted January 16, 2014 Share Posted January 16, 2014 No it runs just fine on my Laptop. (Mac Firefox/Chrome)But I don't get any cars on my Ipad/Nexus5. Since I'm also new to phaser/gamedev in general I'm curious; why are you using a custom loop instead of the update() function ? Link to comment Share on other sites More sharing options...
paperElectron Posted January 17, 2014 Share Posted January 17, 2014 Yeah. what Pixelguy said above. Why are you running your own gameloop, and with setInterval at that? setInterval is in no way accurate enough to use for a game loop. At the very least you should be calling requestAnimationFrame, but then you would be throwing away all of the methods that Phaser already provides you in the update() function. Link to comment Share on other sites More sharing options...
Benjans Posted January 17, 2014 Author Share Posted January 17, 2014 Hey guys, thank you for your reply. I'll try to add more cars to see if it's still smooth...My game is based on Cookie Clicker mechanism: every second, a new inhabitant comes to your town.Update is called 60 times per second, the goal of the update function is to run as often as possible, not at a regular interval.That's why I used setInterval... Maybe I'm doing wrong? Link to comment Share on other sites More sharing options...
Pixelguy Posted January 17, 2014 Share Posted January 17, 2014 Sorry i am only on my Phone atm. You can use the function "game.time.time" to create a timer inside your loop and check if 1 second of Gametime has passed to spawn a new entity Link to comment Share on other sites More sharing options...
rich Posted January 17, 2014 Share Posted January 17, 2014 The new Timer objects in 1.1.4 will solve this for you totally Pixelguy and Zaidar 2 Link to comment Share on other sites More sharing options...
Recommended Posts