#### Archived

This topic is now archived and is closed to further replies.

# Modifying DXImageList at runtime...

This topic is 5760 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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

##### Share on other sites
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.

##### Share on other sites
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]

Paul.

• 11
• 20
• 12
• 10
• 38
• ### Forum Statistics

• Total Topics
631401
• Total Posts
2999864
×