Grids & Arrays

Get help using Construct 2

Post » Mon Apr 30, 2012 7:35 pm

I'm starting to work with Arrays, and I'm a little lost.

I've got a 9x5 array. And with it, I've created a Grid of blue Sprites.
At the botton left corner, you've got a Martian you can "buy" and place it on the Grid.

Once you've placed it on the Grid, I'd like to store it's UID (or any other value) in the corresponding place on the array.

Also, when you're moving the Martian on the Grid, it snaps to the centre of the blue Sprite. I'm doing it with a ImagePoint. Is there any other (better) way to do it? I've tried using floor() but was unable to make it work.

Download .capx
B
7
S
1
G
2
Posts: 25
Reputation: 1,760

Post » Mon Apr 30, 2012 9:07 pm

How about this? I created XY position variables (gameFieldX and gameFieldY) in the Sprite2 object. I then assigned these values during the array's foreach creation.

The Sprite's able to access the array then by gameField.At(Sprite.gameFieldX and Sprite.gameFieldY).

GridField.capx
B
126
S
7
G
4
Posts: 185
Reputation: 7,233


Return to How do I....?

Who is online

Users browsing this forum: blackhornet, makkancs, TiagoCesar and 15 guests