momothemonster Posted February 10, 2014 Share Posted February 10, 2014 I'm loving Phaser for this project I'm working on. I want to record a user's movement and play it back in a loop, and I've got it working! Desktop performance is great, mobile performance is just OK, so I'd love to get someone else's eyes on my logic to see if I'm doing this in a silly way. My first thought was to enable history on pointers and go through that, but after some testing I thought I'd need to create objects separate from the actual Phaser Pointers so I could tell the difference in code between a real pointer and a virtual one, and so I wouldn't be limited to 10. So I've extended the Sprite object, adding an array of data consisting of a relative Timestamp and a position. When a pointer isDown on the canvas, I start tracking its movements, adding timestamps and positions to the Sprite's data. When the pointer is lifted, I stop tracking and start playback. Codepen here: http://codepen.io/momothemonster/pen/jtsxG Of course - there's a lot more going on in the actual game. I'm doing overlap checks every frame to see if any virtual pointers are over certain tiles, etc. Link to comment Share on other sites More sharing options...
Recommended Posts