I’m trying different methods to link the type ID with the Sprite ID. The reason: once I click on the sprite I need to know which type item is that so I can insert in other type or remove.
Method 1:
InventoryPartCardSprite as integer[-1]
for i=0 to ListPartCardsCategories[0].PartCard.length
InventoryPartCardSprite.length=InventoryPartCardSprite.length+1
InventoryPartCardSprite[i]=CreateSprite(loadimage(ListPartCardsCategories[0].PartCard[i].ImageName))
SetSpritePosition(InventoryPartCardSprite[i],(i+1)*152-152,951)
next i
In this method, as InventoryPartCardSprite is a variable the Sprite ID is auto, so it will start at 1001, 10002, etc. so once i use GetSpriteHit(x,y) I’m not able to know which type I clicked.
Method 2:
for i=0 to ListPartCardsCategories[0].PartCard.length
ListPartCardsCategories[0].partcard[i].SpriteId=createsprite(LoadImage(ListPartCardsCategories[0].PartCard[i].ImageName))
SetSpritePosition(ListPartCardsCategories[0].partcard[i].SpriteId,(i+1)*152-152,951)
next i
In this method, I created the integer SpriteID inside the type, but still, It starts with 1000, 1001, 1002 and my type IDs follows the array sequence (0,1,2,etc.) . I would be able to get the type ID trough a loop, but not sure if its a fast method.
Method 3:
for i=0 to ListPartCardsCategories[0].PartCard.length
createsprite(i,LoadImage(ListPartCardsCategories[0].PartCard[i].ImageName))
SetSpritePosition(i,(i+1)*152-152,951)
next i
Here I can link the sprite ID with the type ID, however it won’t accept 0 so I would have to use i+1 and I’m afraid it will get confuse with time.
I’m sure you can come up with something better