Can you get name of a sprite?

So I want to create 64 sprites in a grid, and name then to indicate their grid location, so for example

ImageSprite11 would be the ImageSprite at position x=1,y=1 in the grid

I then want to use the block when any imagesprite Touchdown to carry out an action, but getting the sprite name allows me to determine location in grid so I can use this to lookup a list of lists which is the
logical representation of the grid of ImageSprites.

The name cannot be read. You must create a list of all sprites. For example "ImageSprite1" in the first position of the list, 'ImgeSprite8 "in the eighth position etc. You then use the" AnyImageSprite "component and wanting to set the sprite at the x = 1 position, y = 1 take the name from the list from the eleventh position and put it into the" AnyImageSprite "block

Tks. will try shorty

I did something similar in this project ...

1 Like

Thanks,

Using list works. I use mod as its an 8 by 8 grid to convert index into an x,y mapping. Once I have finished I will put link to gallery for future reference.

Help much appreciated.

as promised, a simple demo

https://gallery.appinventor.mit.edu/?galleryid=ff032d30-4253-4345-a294-53d383b26f7f

That's a nice project, @cadencep45

Consider loading your tiles from a CSV file in your Media folder or a Google Sheet.
That might be an 8 by 8 CSV file of image file names.

Your tile image file names can be coded to give you connectivity hints from a separate a three column table

  • tile image file name
  • from direction (N/E/W/S)
  • corresponding to direction (N/E/W/S)

using the letters NEWS in various combination to tell which of the four directions North, East, West, South are allowed for flow.

You might have anywhere from 0 to 12 possible rows per image file name, given all the possible paths through a tile (4 entry, 3 exit).

Tks,

Created a hard coded 8x8 pattern for demo. Propose something like csv file to hold layout as objective is multiple levels and each 8 x 8 pattern = a separate level. Hence 2 screens, one level and second one to play level.

Re names to give connectivity hints. Thinking though this at the moment, its a good idea, need to figure out how it works when you have multiple possible exists ( A T junction pipe or a cross roads piece )

WFH gives me lots of thinking time !