Modifying DXImageList at runtime...

Started by
2 comments, last by Paul Wren 21 years, 7 months ago
Hi everyone. I am a bit of newbie with DelphiX. I have a scrolling tiled background using TBackground sprite which references a bitmap stored in a DXImageList component. My problem is this. I want to change the tiles graphics during the game (depending on game level etc) but I am having difficulty doing this. If I try something like.. (from memory here...) DXimagelist.items.find(''tiles'').picture.bitmap.canvas.pixels[5,5]:=cllime; for example, just placing a pixel somewhere, it doesn''t have any effect on the tiles. Sometimes the background sprite stops working completely and freezes. What am I doing wrong here? I''m assuming this has something to do with how DelphiX "creates" the dximagelist. Because if I modify the image before DXdraw starts then my modifications take effect. But how do I do it once the background is up and running? Thanks for any help in advance... Paul
Advertisement
it doesn''t work because DelphiX creates a DirectDraw surface for every image in your imagelist. If you modify the picture, you don''t modify the surface but the surface is what is actually drawn.
There''s an example for dynamically created image lists that ships with DelphiX.
I think deleting the items in an image list and adding them again with new pictures does the job.
In order to modify it at run time you'll need to access the image surface:

with DXImageList.Items.Find('tiles').PatternSurfaces[0].Canvas dobegin     Pixels[5,5]:=clLime;     Release;//You must include this at the end of your canvas manipulationend;   


EDIT: Of course if all you intend to do is load a totally new set of tiles then I suggest using the Delete and Add methods, or use the LoadFromFile along with ImageLIB to create a DXG ImageList file for each level.


[edited by - michalson on September 12, 2002 8:55:14 AM]
Many thanks guys. Very helpful.


Paul.

This topic is closed to new replies.

Advertisement