Check sprite neighbours animation

Before proceeding, please use the forum search feature at the top of the page to check if your question has already been answered.

How do I…

image_2022-11-17_18-10-23
how can I check the animation number of sprites around red one (in centre)

What is the expected result

I want to store animation numbers in scene variables

  1. Get the centre X & Y of the middle tile. Store these 2 values into variables named MiddleTileX and MiddleTileY.
  2. Code the following:

You will now have a structure with 8 sub-child values;

TileAnimation[-1][-1]
TileAnimation[-1][0]
TileAnimation[-1][1]
TileAnimation[0][-1]
TileAnimation[0][1]
TileAnimation[1][-1]
TileAnimation[1][0]
TileAnimation[1][1]

which hold the animations for the following tiles:

image

Wrote this code:


But it stores only [1][1] tile animation value:

Yeah, apologies. I wrote those events but didn’t test them.

This one works:

2 Likes

Now it is working only for positive x_inc and y_inc indexes in structure:


For [0][-1] it should return 1 but it returns 0

How are you setting the variables MiddleTileX and MiddleTileY?

Also, you should have those events in a conditional event, so it doesn’t get run every game frame.

I deleted setting of that variables by accident now algorithm working nice.
Thank you!