Language…
8 users online: crm0622, Danik2343, Firstnamebutt,  Losoall, pnaha,  Segment1Zone2, tOaO, Zavok - Guests: 161 - Bots: 388
Users: 64,795 (2,381 active)
Latest user: mathew

Hey, listen! DO NOT use the "gfxoffset" NPC codes! This tells you how to properly align NPC hit boxes.

Seriously, don't. It will only cause you and the players trouble.

So I was making my Pikmin Forest level, and I found something intimidating about Super Mario Bros. X that I think you should know about.

So I decided to change the Pikmin graphics simply because there are more Pikmin available in this new art style, and I think this new art style looks better.

Anyway, what I wanted to do is change the size of the hit boxes, and this is what it initially looks like (using PGE editor).



As you can probably see, the hit box (the red box) isn't aligned the way I want it. That might simply make you think, "Ooh, I'll simply change "gfxoffsetx" to align the hit box." That's exactly what I did. This is where I want the hit box to be. (Note the "X Offset" property.)



So I tested the collision behavior in Super Mario Bros. X one night and everything seemed to be working properly. It was getting late, so I went to bed.

The next morning, I started testing it again, and it was NOT working properly! "What the heck!" I thought, "How's it not working properly? It was working properly last night, wasn't it?"

Now comes the jarring part. You saw how the hit box was aligned properly in the second screenshot, right? Well, I found out that if I were to press the button with the arrow pointing right on it, which makes the sprite "face right", this happens.



What?! The hit box is misaligned?!

If I change the "X Offset" from -3 to 3, the hit box aligns.



But then the hit box won't be aligned when I make it "face left".



What?! So how do I align the hit box?!

The solution is simple. First of all, make sure the "Offset" properties are set to 0 and turned off. Never touch them. To align your hit box, open up your NPC in a graphics editor and add blank columns of pixels to a side of the graphic to align your hit box the way you want it. The number of blank columns to add would be DOUBLE the number that you would type in for the "gfxoffset" property. Make sure you edit the graphic and the mask this way, and don't forget to change the "gfxwidth" and "gfxheight" properties accordingly.



I typed in 3 for the offset value, so I add 6 blank columns of pixels to the right of the graphic and the mask to align the hit box.

Now the hit box is aligned properly.



See?



Any objections, ladies and gentlemen? Do you think "gfxoffset" still has a use after this tutorial or no?

Click the character on the right side of my layout to visit my Discord server and discuss and play and look at and get updates and sneak peeks of the games and other things I'm making.

The authors of these 2 My Little Pony fan games have removed their games from the Internet.
Rise of the Clockwork Stallions has been updated! Download My Little Pony: Rise of the Clockwork Stallions DX: Director's Cut and My Little Pony: Magic Shards now! Spread this link!

Oh, interesting tutorial! Will keep this as a sticky for it to not be together with the level threads.

Haven't done much with NPC codes yet, but this can be useful.
Actually, the gfxoffset codes can be useful if the hit-box is aligned to the left of the graphic instead of the center. Also, if changing the hit-box misaligns the graphic somehow, gfxoffset=0 will fix it.