Mac OSX Does collision mask flip when xscale = -1

J

Joe Banko

Guest
I have setup a collision mask on one of my characters so it only covers the left 2/3 of the image. When I am moving to the right the 1/3 of the image I don't have masked goes past any wall it runs into which is what I want. However going to the left when I use xscale = -1 to flip the image the 1/3 of the image now contacts the wall. It would seem that the collision mask hasn't flipped along with the image. Isn't the mask supposed to do that or is there a mask xscale that needs to be flipped as well? Or is there some code that I need to execute to change the location of the mask in the sprite?

Thanks in advance for clarifying this for me.

Joe B
 

Slyddar

Member
The mask will flip too if you are changing the image_xscale, and have not changed the objects default mask, or are not drawing the sprite in another matter which ignores image_xscale.

You can draw the mask, which might help, by adding this to a draw event.
Code:
draw_self();
draw_set_alpha(0.3);
draw_rectangle_colour(bbox_left,bbox_top,bbox_right,bbox_bottom,c_red,c_red,c_red,c_red,false);
draw_set_alpha(1);
 
J

Joe Banko

Guest
First; thanks for the tip!
Wow, where have I seen that code before????
I just finished the Tile Based Platformers course (excellent) and am now working thru the DND series while I wait for the course on sloping platforms. You should know I'm hooked on your courses. I do have one other question; how the heck did you get the sprites to look so good on the DND course? Couldn't find the sprites you used on the OpenPixelProject site but I did find them elsewhere, looked at maybe 50 different sites. When I changed the resolution down to sizes in the course they looked pretty raggy so I'm assuming you ran them thru Photoshop/Gimp/Spriter. I found some other sprites that scale down OK and I'll use them until I go to the 128 X 128 character sets I purchased.

Thanks for all the GREAT courses/tutorials!

Joe B
 
J

Joe Banko

Guest
That answers that. The mask ISN'T flipping. I pasted the above code into an ExecuteCode DND before the DrawTransformed DND in the o_player Draw Event. I used c_aqua instead of c_red, easier to see the mask. Here's what it looks like:
 

Attachments

HayManMarc

Member
Best way to get a good answer is to show your code for the object in question.

(Sorry, didn't see the pic.)
 
Last edited:

curato

Member
I would be curious about the code too. I am changing the x and y scale in my project specifically to change the collision an it work flawlessly
 

Slyddar

Member
Thanks for all the GREAT courses/tutorials!
haha, hey Joe, thanks for the kind words. If you've done my Tile based course, it will be a step backwards doing the D&D series. D&D is so limited in tutorials, as showing anything complicated can get so lengthy. Happy to have you along for it though.

Note that flipping the mask is never really a good idea if the object relies on collisions. If you flip the mask and it's not exactly a mirror flip, you can get stuck when you flip next to a wall. This is the reason in the D&D course I don't use image_xscale, instead assigning the facing direction to the variable 'facing', and using that to change the direction the sprite is shown. The mask stays in it's position to avoid collisions. It's something I would of liked to not have in the tile course, but I used a mirror-able mask, so left it in.

how the heck did you get the sprites to look so good on the DND course?
I scaled them by a scale of 50% a few times. Doing it by half like that seems to leave them looking cleaner.
 
Last edited:

TheouAegis

Member
Wait, you changed image_xscale? I don't see that, I see you using a custom variable facing in a draw call. That's not the same thing.
 

Relic

Member
Agreed, there is a difference between setting image_xscale=-1 and drawing a sprite.

The former will affect all automatic drawing and the collision mask too. The latter allows you to manipulate the what is drawn regardless what the x, y, image_scale, image_angle etc values are.
 
J

Joe Banko

Guest
haha, hey Joe, thanks for the kind words. If you've done my Tile based course, it will be a step backwards doing the D&D series. D&D is so limited in tutorials, as showing anything complicated can get so lengthy. Happy to have you along for it though.
Starting to see how much more complicated DND can be, but I thought I'd give it a whirl. I'm a long time text based coder but I like to delve into the "easier" graphic/iconic way of programming. IMNSHO nothing will ever replace typed code. Of course this is from a guy who thought languages would never replace assembler code. Thanks again for the insights. I've started getting notices from the facebook page so I'll know what's up and I'll probably be on here quite a bit.

joeb
 
J

Joe Banko

Guest
Wait, you changed image_xscale? I don't see that, I see you using a custom variable facing in a draw call. That's not the same thing.
I did this in the D&D code so it's different than in the code version and appears to more difficult to get what you want unless you use ExecuteCode blocks and if you start using a lot of them why not just stay with code.
Thanks for the response!
joeb
 
Top