Woot new issue
2 posters
EMS Forums :: Discussion :: Game Maker :: Questions
Page 1 of 1
Woot new issue
How do I change a sprite's origin?
I have this code:
It's for swords =)
I have this code:
- Code:
if swinging = false{ //if not swinging
if !keyboard_check (vk_space){ //if not pressing space
if global.dir = 0{ //if facing left
image_angle = 115} //sword non-swinging left position
else{ //if facing right
image_angle = -20}} //sword non-swinging right position
if keyboard_check (vk_space){ //if pressing space
swinging = true
alarm [0] = 7}} //How long swinging after release of space
else{ //if swinging
if global.dir = 0{ //if facing left
image_angle +=20} //spinning speed when going left
else{ //if facing right
image_angle -= 20}} //spinning speed when going right
if global.dir = 0{
//insert change origin to x=27, y=26 here}
else{
//insert change origin to x=5, y=26 here}
It's for swords =)
Joegernaut- Corporal
- Posts : 78
Join date : 2011-04-18
Age : 27
Location : New Zealand
Re: Woot new issue
There's a function called sprite_set_origin, or something along those lines. Look for it in the manual.
EDIT: Also, why do you need to change the origin of the sprite? I'm assuming you're wanting to flip the sprite, correct? If so, just use image_xscale. Set it to 1 for right, and -1 for left.
EDIT2: Why are you using 2 if statements that checks the same thing?
EDIT: Also, why do you need to change the origin of the sprite? I'm assuming you're wanting to flip the sprite, correct? If so, just use image_xscale. Set it to 1 for right, and -1 for left.
EDIT2: Why are you using 2 if statements that checks the same thing?
Water Chicken- Lieutenant
- Posts : 254
Join date : 2011-03-22
Age : 24
Location : Chandler, Indiana
Re: Woot new issue
Admin edit: Yes, that does actually go against the rules.
just tell me what to put in <insert change origin>
I've tried both the things you told me already to no avail.
just tell me what to put in <insert change origin>
I've tried both the things you told me already to no avail.
Joegernaut- Corporal
- Posts : 78
Join date : 2011-04-18
Age : 27
Location : New Zealand
Re: Woot new issue
sprite_set_offset is the functions name, my bad.
sprite_set_offset(ind,xoff,yoff) Sets the offset of the sprite with the given index.
So ind would be the sprite, and xoff and yoff would be the x/y offsets.
EDIT: Then again, maybe you can't change a sprite's offset during the game...
sprite_set_offset(ind,xoff,yoff) Sets the offset of the sprite with the given index.
So ind would be the sprite, and xoff and yoff would be the x/y offsets.
EDIT: Then again, maybe you can't change a sprite's offset during the game...
Water Chicken- Lieutenant
- Posts : 254
Join date : 2011-03-22
Age : 24
Location : Chandler, Indiana
Re: Woot new issue
nope didn't work
Joegernaut- Corporal
- Posts : 78
Join date : 2011-04-18
Age : 27
Location : New Zealand
Re: Woot new issue
Well if that didn't work, then I don't know what else you could do besides changing the sprite for the sword object.
EDIT: I probably worded that wrong. Changing the object's sprite meaning change it depending on the global.dir variable.
EDIT: I probably worded that wrong. Changing the object's sprite meaning change it depending on the global.dir variable.
Water Chicken- Lieutenant
- Posts : 254
Join date : 2011-03-22
Age : 24
Location : Chandler, Indiana
EMS Forums :: Discussion :: Game Maker :: Questions
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|