How do I create drag and drop sprite movement on grid

Get help using Construct 2

Post » Wed Mar 18, 2015 2:27 am

Hi there, I've been looking into making some games for fun and have made some very basic games. I was wondering if anyone could put me on the right track with my latest goal.


I need help with setting up a chess like grid or board that my sprites can move on. I want a few sprites that can move in different ways like with different pieces in chess.
More specifically I want to be able to select a sprite, click a move and have the squares that the sprite can move to light up. then only once a valid square is clicked have the sprite move there.
I also want to make it so that if a sprite clicks on another that is within its valid range it will do damage based on the variables for hp and damage I have setup.


I can do this normally but with grid movement and restrictions on movement and attacking I have got myself stuck.
Any help would be much appreciated, whether it is a link to a tutorial that my searches havent found or whether you write up an example for me.

Thanks in advance
B
3
Posts: 3
Reputation: 181

Post » Wed Mar 18, 2015 6:07 am

I'd say have a look at RexRainbow's grid movement: plugin-board-layout2board-behavior-grid-move_t69647

It does support grid based pathfinding and listing possible moves.

For Drag&Drop, I think there are methods for finding the logical coordinates for a world coordinate. It's really quite an elaborate system, and I'm very happy with it. Don't hesitate to keep asking if you have any confusion after looking over this plugin system.
B
14
S
5
G
1
Posts: 189
Reputation: 1,536

Post » Fri Mar 20, 2015 1:45 am

Thanks, I have gone through this tutorial scirra(.)com/tutorials/864/board-movements on rexrainbows gridmovement and understand it although I am have trouble moving the piece with the mouse. I have tried a few things but havent had any luck as this tutorial only covers gridmovement with arrow keys. I'm just not sure how to tell the sprite to go to a certain clicked position after selecting it. (I have set a boolean instance variable that is toggled by clicking the piece for the selection). Thanks again :)
B
3
Posts: 3
Reputation: 181

Post » Fri Mar 20, 2015 5:51 pm

Theres an expression for getting the Logical X and Logical Y. use Board.PXY2NearestPX(X, Y) and Board.PXY2NearestPY(X, Y)
B
14
S
5
G
1
Posts: 189
Reputation: 1,536

Post » Sat Mar 21, 2015 5:13 am

Thanks, I shall give it a try
B
3
Posts: 3
Reputation: 181


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, aldi45mts and 10 guests