GameEngine2D

Reply
Accepted Solution

HOW: Force Update

Hi

I'm trying to force an update or redraw I guess 

 

my issue is

 

I'm replacing spriteTiles inside a SpriteList, basicly just switching and index to get a different color

so I got a function to flood fill an area and works great INSTANTLY but what I want is to wait a little between each replace so I can get a more estetic look :smileyhappy:

 

been trying with thread.Sleep and environment.tick nad it works, but the tiles get drawn all at the same time at the end, not one by one.

 

so, is there a way to, replace the spritetile and for a refresh, not wait till all are replaced?

 

thanks for any help

Please use plain text.

Level 3

Level 3
Daveid
Posts: 45
Registered: ‎07-04-2009
Message 2 of 7 (195 Views)

Re: HOW: Force Update

[ Edited ]

This doesn't sounds about how to force update, it sounds like you don't want to update some of them!

Instead of updating all of the sprites why don' tyou just update one every frame or ever few frames or something

This would make a wave as each one update;

 

ie

 

 

private SpriteList _spriteList;
private int _spriteToUpdate = 0;
public void Update(float dt){
    UpdateColourOfSprite(_spriteList[_spriteToUpdate++]);
}

 

Please use plain text.

Re: HOW: Force Update

that didn't actually helped, I got no idea how to do that :smileyhappy:

sorry newbie here :smileyhappy:
Please use plain text.

Level 3

Level 3
Daveid
Posts: 45
Registered: ‎07-04-2009
Message 4 of 7 (183 Views)

Re: HOW: Force Update

I'm not sure what you're asking to be honest :smileyhappy:

 

You said you have tiles and you don't want to change the colour of all of them at once, but you tried Thread.Sleep and there is a delay, but then they all change at once.

 

So I propose instead of changing them all..... just change some, but change which you are changing each update, or less 

 

I think you you maybe read the samples in the docs or something, you seem to not know what you're asking / doing >_> that's the impression i get anyway

Please use plain text.

Re: HOW: Force Update

it's weird

 

cause I can see the function writing lines in the console at the right timing but the tile is not updated, that's why I'm thinking it's a redraw thing, so the function is looping is doing what it supposed to do, but NOT on the board until the loop is finished and then it draws all the tiles at once.

 

Thanks for the help and excuse me for been all over the place :smileyhappy:

Please use plain text.

Re: HOW: Force Update

Hello varo_mix,

 

If I understand your question correctly, an important point to remember is that as soon as you update the state of a SpriteTile (colour, position, etc.), or any other objects that are visible on the screen, you will have to wait until the GameEngine has rendered and the GraphicsContext's buffers have been swapped (SwapBuffers()) before you will notice a visible difference.

 

Bearing this in mind, you are seeing the last colour that you set it to an not the previous colours because the Director has not had a chance to Render and neither have the buffers been swapped, and so when it gets to the point of rendering, the colour is has for the SpriteTile will be the last one you set. 

 

To achieve the effect of the tiles changing colours, you could to do one colour change per frame. On each frame you could increment the TileIndex1D property until you reach the maximum number of tiles that you have. 

 

spriteTile.TileIndex1D = spriteTile.TileIndex1D + 1;

Doing the change each frame, may be too quick to actually notice, so you could look at the Stopwatch class, which provides a stopwatch timing mechanism. With some simple checks, you could change the colour at certain intervals, e.g. Every 500ms. 

 

Hope this helps

James.

PlayStation®Mobile Dev Team
Please use plain text.

Re: HOW: Force Update

Thanks James you mentioned the swapBuffers and that just did it for me

 

so it works now

 

this is what I'm doing to FORCE the UPDATE :smileyhappy: I get what I want hehe

 

 

public void Delay(int ms)
		{
		    int time = Environment.TickCount;
		
		    while(true)
		        if(Environment.TickCount - time >= ms) return;
		}
		
		public void Infekt(Block selBlock)
		{
			
			Support.SetTile(selBlock.Sprite, 1);
			Delay(50);
			
			
			
			// Forcing update :smileyhappy:
			Director.Instance.Render();
			Sce.Pss.HighLevel.GameEngine2D.Director.Instance.GL.Context.SwapBuffers();
			Director.Instance.PostSwap();
			
		}

 

Please use plain text.
This widget could not be displayed.
Announcements

Welcome to the PlayStation Mobile Developer Forums


This is a community for the discussion of technical topics with other developers and SCE engineers. Posting ideas/requests are also appreciated. Join the discussion!

PlayStation®Mobile開発者フォーラムでは世界中の開発者の皆様と一緒に、議論や情報交換が可能です。SCEも議論に参加し、皆様の開発をサポートします。アイデアやリクエストも大歓迎です。ぜひご参加ください。

PSM Developer Registration (for free) on PSM DevPortal is required to post on the forum.
Please sign out then sign in again to the forum and PSM DevPortal after you have completed the registration.

フォーラムへ投稿をするにはPSM DevPortalへの登録(無料)が必要です。
登録後はフォーラムと PSM DevPortalを一度ログアウトし、再度ログインしてください。






Recent News