pistacchio Posted September 29, 2015 Share Posted September 29, 2015 Hi,you can see my problem here: http://phaser.io/sandbox/edit/XrmIIalg Basically, in the update() function you can use BitmapData.circle() and its gets drawn and each frame BitmapData.clear() clears the screen. Works ok. If I draw the circle pixel by pixel with setPixel(), BitmapData.clear() has no effect. Any idea? Link to comment Share on other sites More sharing options...
tips4design Posted September 29, 2015 Share Posted September 29, 2015 Are you sure it isn't your function that actually draws all those circles? Yes, it's something with Phaser. Link to comment Share on other sites More sharing options...
rich Posted September 29, 2015 Share Posted September 29, 2015 Call BitmapData.update after and it'll clear itself down. Link to comment Share on other sites More sharing options...
tips4design Posted September 29, 2015 Share Posted September 29, 2015 Call BitmapData.update after and it'll clear itself down.And why using Circle the update is not necessary? Link to comment Share on other sites More sharing options...
rich Posted September 29, 2015 Share Posted September 29, 2015 setPixel modifies the pixel array buffers directly. When that modification is done the bmd is flagged as dirty and the array buffer is copied over the bmd again. Methods like circle modify the bmd canvas object itself (using Canvas drawing primitives like arc and fillRect). Basically if the bmd is updated via setPixel and you want that instantly reflected in the internal array then call update().Equally though if you draw to the bmd via Circle and then want to draw over the top with setPixel you need to do: circle, update, setPixel. The reason that methods like Circle don't automatically call update is that it's a quite expensive thing to do. If you don't actually need to use the pixel data then it's a waste of CPU updating it all each time you draw a primitive to the bmd. Also doing it this way means you can do lots of single canvas draw calls (like several circles and rects) and then when finished do one update call to refresh the pixel array. tips4design 1 Link to comment Share on other sites More sharing options...
Recommended Posts