The attached .apk and .aia demonstrate a 4 item by 4 item grid of non-moving sprites, that are randomly located on the screen when it is initialized. The “dirt” objects blink on and off when touched (using the fixed image size and blank image label trick).
Since, apparently, there’s no way to iterate or otherwise programmatically manipulate sprites (objects in general?), I created an if/then table (since I don’t see the equivalent of a “switch” statement anywhere) that matched specific strings to specific sprites along with enabling specified actions on them (setting X and Y coordinates), created a list that contained those strings and shuffled it, then assigned each item in that list a unique X,Y coordinate via a for each item loop.
Note: this is a prototype, demonstration case. The final game is going to have much more logic and anywhere from 160 to 300 sprites (of the type referenced), so unless there’s a better way, this is obviously going to involve hacking the XML and JSON to create the blocks and objects (already done). Right now, there’s two sets of blocks for each object, one in the if/then table, and one for the action to take when a sprite is touched, so we’re looking at, quite possibly, nearly 1000 blocks on the Screen where the action is taking place.
Question 1: Am I correct in my understanding that there’s no way to directly convert a variable name into an object name that can be manipulated? I.e., instead of having an if / then table that calls a procedure after mapping the content of a variable to a specific object, being able to pass the name of an object (sprite) to a procedure directly, with maybe some conversion logic that says, “turn this string into an object name”?
Question 2: is there any more rational way of dealing with 160 to 300 sprites than creating a block of duplicate logic for each and every one? It seems like I should be able to dynamically derive the name of a sprite that happens to be occupying a particular X,Y coordinate, and then pass that to a single set of code blocks that define what should happen.
I can use the Canvas.Touched block to derive the X and Y coordinates of a touch, derive the sprite name from a list (lookup table) containing the name and location of every sprite (since they’re static and not moving), and then use the my already existing if/then look up by sprite name table to trigger specific actions (like setting the visible/invisible property of a particular sprite, or the picture property)… but this seems incredibly hackish and perverse, when the system already knows exactly what sprite I just touched, and should then be able to invoke the standard blocks associated with it. Not to mention that I suspect this is going to be horribly inefficient along a number of vectors (and make the AB block editor interface spaz out completely when the lookup tables are touched).
Am I missing something?