on 12-06-2012 06:15 PM
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 ![]()
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
Solved! Go to Solution.
12-06-2012 08:10 PM - edited 12-06-2012 08:10 PM
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++ ]);
}
on 12-06-2012 10:37 PM
on 12-06-2012 10:40 PM
I'm not sure what you're asking to be honest ![]()
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
on 12-06-2012 11:19 PM
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 ![]()
on 13-06-2012 02:25 PM
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.
on 13-06-2012 03:28 PM
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
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
Director.Instance.Render();
Sce.Pss.HighLevel.GameEngine2D.Director.Instance.G L.Context.SwapBuffers();
Director.Instance.PostSwap();
}
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を一度ログアウトし、再度ログインしてください。


Website ©2013 Sony Computer Entertainment Europe
All content, game titles, trade names and/or trade dress, trademarks, artwork and associated imagery are trademarks and/or copyright material of their respective owners. All rights reserved. [more info]
%%http://community.eu.playstation.com/t5/Announcements/Beta-Trial-Information/td-p/11386362
best_shooter.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_driver.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_performer.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_footballer.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_fighter.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_creator.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_action_player.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
dev2.png%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/Producer-and-Developer-Ranks/td-p/18407352
trophy.gif%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/The-Community-Awards-FAQ/td-p/18407096
PSlogoSM.png%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/Online-Support-Coordinator-rank/td-p/18414870