Page 1 of 1

Custom related questions

Posted: Fri Jan 05, 2024 10:52 pm
by SuperYoshi
So this is probably gonna sound like a problem with a super easy solution I apologize I am new to all of this. I recently just made a custom NPC just to basically have it make a message and nothing else. Two problems I have is first the size I want to make it a bit smaller but when I try to make the image smaller in my image editor it just becomes distorted. Basically I am asking if there is a way to resize the sprite within SMBX. My other problem is it won't stop jumping. I looked through all the code and I can't see anything that would cause it to just to constantly jump.

Re: Custom related questions

Posted: Sat Jan 06, 2024 10:53 am
by Emral
1. Regarding size:
There are 2 separate files. One is for the editor size, one is for the size in game. The editor file is the .ini file, the one for the game can be either a .txt, or embedded in the .lua as part of the "setNPCSettings" block. You probably have the latter.
In your ini, adjust gfx-width and gfx-height to match the size of one frame on the sprite sheet. physical-width and physical-height exist too, and define the size of the hitbox. The same fields exist in the txt/lua and are called gfxwidth/gfxheight and width/height respectively here. Just make sure the values match between the ini and txt/lua and you should be good.
For more information: This docs page

2. Won't stop jumping
Check the onTickNPC of the code. There should be a comment near the bottom that reads "Execute main AI of the NPC. This example just jumps forever". Remove the lines below that comment that set v.speedY when the NPC is on the ground. This piece of code is there as a check to confirm that your code is loaded correctly, and as a starting point for people to replace with their own.

Re: Custom related questions

Posted: Sat Jan 06, 2024 11:57 am
by SuperYoshi
Thank you so much