How do I make sprite move to empty space

Get help using Construct 2

Post » Mon Mar 24, 2014 9:02 pm

here is problem that i want solve:
on click -> move object-> empty space next to object

i want sprite move exactly as ''picture puzzle'' gadget on windows 7
Image

there is no behavior witch can make this simple and i don't have idea hot to do it.
B
6
S
3
Posts: 15
Reputation: 610

Post » Mon Mar 24, 2014 10:46 pm

There's a few ways you can do it.. it's not that simple.

I'd set up some sort of invisible grid that underneath each puzzle tile. Number the grid so you can figure out which pieces are eligible for moving since the empty space will be different each time. Then you need to figure out which direction the piece has to move. Once you have all that then you need to move the piece --if you don't know how to do that I would suggest creating a test project just to figure out how to move a sprite from point A to point B - use Set Position or Bullet Behavior - you just need to figure out how/where to stop the sprite (again an invisible grid would work great here).
B
98
S
32
G
16
Posts: 1,204
Reputation: 16,715

Post » Sat Nov 15, 2014 8:31 pm

thanx for answer.
im still struggling with that and need some help; in last 3 days i was try many options but none of them work.
it should be more easyer if there is way to make movement like:
"on click" -> "sprite1" = - "sprite1" set direction to "empty space"
- "sprite1" move for 100px over 1 second
so after that sprite1 will be on that empty space.

bullet behavior making weird movement, when it finds angle (for example he need go 100 px up), it always move 1 px on left when going up.
B
6
S
3
Posts: 15
Reputation: 610

Post » Sat Nov 15, 2014 9:13 pm

If you're happy with having squares instantly swapping positions all you have to do is check if a square is a square length away. If it is just swap positions of the objects. All in all 1 event for the moving and another for randomly scrambling it yet still being solvable,
https://dl.dropboxusercontent.com/u/542 ... 6tile.capx

For a more caviar version here's one I did a while back.
viewtopic.php?f=147&t=64493&p=551976&hilit=9tile#p551976
B
92
S
32
G
109
Posts: 5,291
Reputation: 70,993


Return to How do I....?

Who is online

Users browsing this forum: divsyntax, volumetv and 17 guests

cron