osinski Posted October 21, 2014 Share Posted October 21, 2014 Hey!In my game I have some groups of sprites I dont need to redraw every frame. Some backgorunds, GUI, decoration. Even games objects, when players do nothing. Can I select what sprite I need to redraw at current moment?Thx Link to comment Share on other sites More sharing options...
lewster32 Posted October 21, 2014 Share Posted October 21, 2014 What do you mean by redraw? All sprites on the screen will be redrawn every frame regardless, as the screen is completely cleared before each render update. If you want a sprite to not be rendered, setting its .visible property to false will make it skip being rendered (and thus disappear) until you set it back to true. There is however a plug-in which will 'hold' the current frame without clearing it under certain circumstances, which is useful for mobile and laptops: https://github.com/photonstorm/phaser-plugins/tree/master/SaveCPU Link to comment Share on other sites More sharing options...
xerver Posted October 21, 2014 Share Posted October 21, 2014 You can draw a group to a renderTexture, then use that texture as a single sprite. That way you can rerender the renderTexture manually when needed, works great for non-often changing complex groups. http://examples.phaser.io/_site/view_full.html?d=display&f=pixi+render+texture.js&t=pixi%20render%20texture Link to comment Share on other sites More sharing options...
osinski Posted October 21, 2014 Author Share Posted October 21, 2014 What do you mean by redraw? All sprites on the screen will be redrawn every frame regardless, as the screen is completely cleared before each render update. If you want a sprite to not be rendered, setting its .visible property to false will make it skip being rendered (and thus disappear) until you set it back to true. There is however a plug-in which will 'hold' the current frame without clearing it under certain circumstances, which is useful for mobile and laptops: https://github.com/photonstorm/phaser-plugins/tree/master/SaveCPUIts nice plugin, thx! But It stops render at all. I want to stop render after my gamescreen created and rendered only a some area of game screen. For example when user dont click on gamescreen - I want to render only this area in the red square http://joxi.ru/dp27OkW3iX8Y27After users clicked on gem - only gems area, and timer area, but not buttons, background, etc. Is it possible? Link to comment Share on other sites More sharing options...
xerver Posted October 21, 2014 Share Posted October 21, 2014 Its nice plugin, thx! But It stops render at all. I want to stop render after my gamescreen created and rendered only a some area of game screen. For example when user dont click on gamescreen - I want to render only this area in the red square http://joxi.ru/dp27OkW3iX8Y27After users clicked on gem - only gems area, and timer area, but not buttons, background, etc. Is it possible? It is, I just told you how, and linked an example. Link to comment Share on other sites More sharing options...
osinski Posted October 21, 2014 Author Share Posted October 21, 2014 It is, I just told you how, and linked an example.Sorry, just had seen your answer after I published mine). Thx, i'll try that Link to comment Share on other sites More sharing options...
Recommended Posts