one code for all images

blursea
08-20-2001, 02:09 PM
i writed a collision code between the player and a block, i duplicate that block many times, so how can the other blocks have the same code without repeating th code?

BillSoo
08-20-2001, 02:12 PM
If you mean you have a Image or PictureBox control that you repeated many times, you can make them part of a Control Array. That way, they all use the same event code.



"I have a plan so cunning you could put a tail on it and call it a weasel!" - Edmund Blackadder

blursea
08-20-2001, 02:21 PM
how can i make them part of a control array, can you give an exemple please

BillSoo
08-20-2001, 02:28 PM
Suppose you start with one picturebox. You make it a control array by setting its INDEX property to 0. You then copy that picturebox and paste it to the form. The result is a second picturebox the same as the first except that its INDEX property is 1. You continue to paste these boxes to the form until you have as many as you need.



"I have a plan so cunning you could put a tail on it and call it a weasel!" - Edmund Blackadder

Squirm
08-20-2001, 04:50 PM
or, as might be more useful, you can create them at runtime provided you have a control with index 0.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum