Sprite Change With Direction Issues
#1
Posted 11 March 2012 - 12:42 AM
FIRST ISSUE
http://i44.tinypic.com/1es02a.png
SECOND ISSUE
http://i39.tinypic.com/muk6kp.png
Any help would be appreciated, thanks guys c:
#2
Posted 11 March 2012 - 02:26 AM
#3
Posted 11 March 2012 - 02:34 AM
image_angle = direction
#4
Posted 11 March 2012 - 02:36 AM
direction = point_direction(x,y,mouse_x,mouse_y);
#5
Posted 11 March 2012 - 02:44 AM
direction = point_direction(x,y,mouse_x,mouse_y);
That's what I have coded so that is shoots where the mouse is positioned, but no matter where I click, the sprite is always the same one, when like I said, I want it to change based on which direction it's going in. If you follow.
#6
Posted 11 March 2012 - 02:47 AM
with the fireball just put
image_angle = direction
Alright, I'll give it a try, but what exactly do I put in for the "direction" part. could you elaborate the code a bit more? Another note; I want the sprite to shoot diagonally if that's where the mouse is. Any help on that would also be appreciated.
#7
Posted 11 March 2012 - 02:58 AM
with the fireball just put
image_angle = direction
after adding in that code, this is my result...
http://i39.tinypic.com/2m6mlut.png
#8
Posted 11 March 2012 - 04:21 PM
#9
Posted 20 March 2013 - 06:56 AM
image_angle=direction;
You need to have the sprite facing right.
Hope I helped.
#10
Posted 20 March 2013 - 09:47 AM
I'm not very familiar with using the mouse, but I would say it should be something like:
create an array. Basically set up 4 different ones based off of what the wizard is doing. This array should go into the wizard's create. Or you can make it a global variable and put it into a controller.
then you need to make a variable like skin =0.
for up:
skinup[0]=spr_wizard_stand_up
skinup[1]=spr_wizard_run_up
then you do the same for the other 3
skindown[0]=spr_wizard_stand_down
Once you complete that, put a code in the step that is like
if mouse's x is greater than the wizard's x {
sprite_index=skinright[skin]}
if mouse's x is less than wizard's x{
sprite_index=skinleft[skin]}
then when you do things like shoot or move, you change the skin variable while that is happening to match the number in the array. That way it automatically goes to that array.
Hopefully that makes sense.
--------------------------------------------------------------
edit:
you could also use a double array.
dir=0
state=0
skin[0,0]=spr_wizard_stand_up
skin[0,1]=spr_wizard_walk_up
skin[1,0]=spr_wizard_stand_down
skin[1,0]=spr_wizard_walk_down
sprite_index=skin[dir,state]
that would start the wizard off standing facing up.
you would then need to change the state variable any time you wanted the wizard to walk etc. whenever he moved you would change state to 1
then you would change the dir variable to match the 0-4 that the directions would be.
Edited by Criminon, 20 March 2013 - 12:53 PM.
#11
Posted 20 March 2013 - 11:50 AM
Easy, already been stated but I'll restate.
On the step event simply put
image_angle = direction
The fireball sprite must be facing directly right. I repeat, in the sprite it must be facing right for the angles to work.
#12
Posted 20 March 2013 - 01:44 PM
For changing the wizard's sprite do something like this:
STEP EVENT:
mydir = point_direction( oPlayer.x, oPlayer.y, mouse_x, mouse_y)
if ( mydir > 45 ){
if (mydir < 135 ) {
sprite_index = UP_SPRITE
} else {
if (mydir < 225) {
sprite_index = LEFT_SPRITE
} else {
if (mydir < 315) {
sprite_index = DOWN_SPRITE
} else {
sprite_index = RIGHT_SPRITE
}
}
}
}
else {
sprite_index = RIGHT_SPRITE
}
That should work but I only scribbled it quickly.
#13
Posted 20 March 2013 - 05:28 PM
For changing the wizard's sprite do something like this:
STEP EVENT:
mydir = point_direction( oPlayer.x, oPlayer.y, mouse_x, mouse_y) if ( mydir > 45 ){ if (mydir < 135 ) { sprite_index = UP_SPRITE } else { if (mydir < 225) { sprite_index = LEFT_SPRITE } else { if (mydir < 315) { sprite_index = DOWN_SPRITE } else { sprite_index = RIGHT_SPRITE } } } } else { sprite_index = RIGHT_SPRITE }
That should work but I only scribbled it quickly.
I think both of our methods would produce the best result. The wizard wouldn't be animated, unless he's cool with that.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











