EMS Forums
Please login or signup to post on the forums.

Join the forum, it's quick and easy

EMS Forums
Please login or signup to post on the forums.
EMS Forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Woot new issue

2 posters

Go down

Woot new issue Empty Woot new issue

Post by Joegernaut Wed Jun 01, 2011 4:28 am

How do I change a sprite's origin?
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 =) What a Face
Joegernaut
Joegernaut
Corporal
Corporal

Posts : 78
Join date : 2011-04-18
Age : 27
Location : New Zealand

Back to top Go down

Woot new issue Empty Re: Woot new issue

Post by Water Chicken Wed Jun 01, 2011 10:26 am

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?
Water Chicken
Water Chicken
Lieutenant
Lieutenant

Posts : 254
Join date : 2011-03-22
Age : 24
Location : Chandler, Indiana

Back to top Go down

Woot new issue Empty Re: Woot new issue

Post by Joegernaut Thu Jun 02, 2011 1:11 am

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.
Joegernaut
Joegernaut
Corporal
Corporal

Posts : 78
Join date : 2011-04-18
Age : 27
Location : New Zealand

Back to top Go down

Woot new issue Empty Re: Woot new issue

Post by Water Chicken Thu Jun 02, 2011 12:58 pm

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...
Water Chicken
Water Chicken
Lieutenant
Lieutenant

Posts : 254
Join date : 2011-03-22
Age : 24
Location : Chandler, Indiana

Back to top Go down

Woot new issue Empty Re: Woot new issue

Post by Joegernaut Sat Jun 04, 2011 1:06 am

nope didn't work
Joegernaut
Joegernaut
Corporal
Corporal

Posts : 78
Join date : 2011-04-18
Age : 27
Location : New Zealand

Back to top Go down

Woot new issue Empty Re: Woot new issue

Post by Water Chicken Sat Jun 04, 2011 12:22 pm

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.
Water Chicken
Water Chicken
Lieutenant
Lieutenant

Posts : 254
Join date : 2011-03-22
Age : 24
Location : Chandler, Indiana

Back to top Go down

Woot new issue Empty Re: Woot new issue

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum