I haven’t found a single tutorial around here that’ll teach it, so i’ll ask instead.
I have planned for making a diablo-like game, pretty well a parody of it with my own aspects and quirks.
I’ve gotten all the animation for it done, and what I want to do is when the player clicks on the ground, the character will load the correct movement image and have the character run or walk in that direction. I’ve seen ones where you use the keyboard, but not the mouse, and I haven’t seen one that changes the image, but I know that can be done. If any of you know where a tutorial like this may be found please tell me, or if you know, please post it for me.
Thanks anyway.:cyclops:
Well, it all depends on how your game works… is it tiled-based?
in any case… all you have to do is to get the location of the mouse when clicked. You can have a movie clip that fills the whole screen. Add an on(release) handler that will send the coordinates of the mouse (in the screen) to your avatar. Your avatar should then translate the screen coordinates to the mouse to the map coordinates in relation to itself.
To move, you just do it with vectors… knowing the starting point and the end point, you can figure out the angle and the magnitude of the vector that points from your starting point to your end point, and then you can determine in which direction your avatar should move per frame.
If there are obstacles in the way, that becomes more complicated. You need to know the A* path finding algorithm. You can find a tutorial on it here:
hope this helped
Creating engaging and entertaining content for designers and developers since 1998.