Moving sprite w/ animation in isometric tilemap

Discussion and feedback on Construct 2

Post » Tue Feb 18, 2014 6:09 pm

Hello everyone,

I have an isometric map w/ an animated sprite, in which I intend to walk from one square to another, but after 2 days, I could not find the right way of doing it.

This is what I have so far: https://db.tt/rngHGcfl

Could somebody please point me the right direction or a tutorial on how to achieve it? The walking should be grid based.

Thanks in advance.
B
9
S
3
Posts: 40
Reputation: 780

Post » Tue Feb 18, 2014 6:27 pm

I am building something like that too.

board game development

Pin hidden movertiles around the player, which should exactly overlap your background tile. (same size etc) These are indicators as to where or how many steps a player can make/move.

Then, on click movertile, have the player move to the movertile.imagepointX(0) and movertile.imagepointY(0) (the exact center of the tile)

I put the x,y coordinate in some temp variables, cos as soon as the player moves the movertile location changes too.
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,572

Post » Tue Feb 18, 2014 6:40 pm

Great!

I just need, now, to digest some of the concepts, since they are still a bit abstract, but the effect is very nice.
B
9
S
3
Posts: 40
Reputation: 780

Post » Tue Feb 18, 2014 6:48 pm

btw, here is a little tip to make isometric tiles easy to place.

Simply set a grid size half of your tiles size. (half width, half height)

Activate snap to grid.

Now when you move tiles around on your laout, they easily snap right next to another tile, pixel precise ;)
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,572

Post » Wed Feb 19, 2014 1:45 am

Which event did you use for movement? The snap to grid tip is awesome, I configured it all, but movement has been a pain!
B
9
S
3
Posts: 40
Reputation: 780

Post » Wed Feb 19, 2014 9:55 am

I use the center of the tiles and mover objects, their image origin points to be precise (object.imagepointX(0) and object.imagepointY(0))

When i click a tile which is eligible to have my object move to, I fetch the X,Y of the image points (from click on tile) and set that in 2 instance variable of the object needing to move (lets call them targetx and targety).

on click tile
set object.targetx = int(tile.imagepointX(0))
set object.targety = int(tile.imagepointY(0))


Then, I have my object.X and object.Y to compare to the object.targetx and object.targety

Either during a loop or with every tick, you can now determine if the target locations are different from the object x,y location, and if so move.

crude example:

every tick
compare 2 variables
int(object.x) not equal to object.targetx
compare 2 variables
int(object.y) not equal to object.targety
action:
object move at angle
angle: angle(object.x,object.y,object.targetx,object.tagety)
pixels to move: 50 * dt


This simply checks if the object x,y is differrent form the target x,y and moves towards the propper position.lennaert2014-02-19 09:56:52
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,572

Post » Wed Feb 19, 2014 12:00 pm

Thank you very much for the help/patience.

Would you think a performance hit could happen if I spawn multiple instances of the main sprite that should move to random directions?
B
9
S
3
Posts: 40
Reputation: 780

Post » Fri Feb 21, 2014 7:43 am

It depends on how it is used/applied.
generally you should be able to add 100s of those kind of objects, but you would just need to process everything more efficient.
I would loop through their instances instead of every tick wise, that sorta thing.

But, you won't know it till you tried :D

Good luck
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,572

Post » Fri Feb 21, 2014 12:25 pm

Thanks a lot. I've managed to make it work except for the diagonals, which get a bit misaligned. Anyway, your guidance was nothing but great.
B
9
S
3
Posts: 40
Reputation: 780

Post » Fri Feb 21, 2014 7:37 pm

edit: oh, a doubble post by accident^^

edit 2: seems the second post updates the first,...so it's weird^^

Anyways, here an example, did you tried to achieve this isometric movement?

https://dl.dropboxusercontent.com/u/26932498/howto/iso_walk/iso_walk.capx
B
24
S
9
G
2
Posts: 294
Reputation: 3,160

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 6 guests

cron