LoginLogin
Nintendo shutting down 3DS + Wii U online services, see our post

SP to SP collision

Root / Programming Questions / [.]

ChaseCZCreated:
How do i make a simple sprite to sprite collision from all sides? (I actually need only bottom but just for more info i want to know all of them)

This is kind of a confusing question. Do you mean that you need to check if collision happens on a specific side of the sprite?

Yes

Hmm... that could be difficult. If you are only checking for one direction you could set the point of origin slightly below the sprite, but this may cause issues with rotating, scaling, BG collision etc.
SPSET 0,496:SPHOME 0,8,16
This can also be done by redefining the sprite:
SPDEF 496,U,V,16,16,8,16
Another way you could do this is set transparent sprites around the sides of the main sprite and check their collision.
X=200:Y=150
SPSET 0,496:SPOFS 0,X,Y:SPHOME 0,8,8

FOR I=1 TO 4
 SPSET I,0:SPCOLOR I,RGB(0,0,0,0)'You may be able to use SPHIDE instead, but I'm not sure if collision happens when the sprite is hidden.
 SPCOL I:SPLINK I,0
NEXT

SPOFS 1,X,Y-16:SPOFS 2,X+16,Y:SPOFS 3,X,Y+16:SPOFS 4,X-16,Y
I am not too confident in my code because I am away from my 3DS, but perhaps someone else will verify or provide a better procedure.

Yeah, i tried one of these but perhaps i got them wrong, so i'll try it again and collision doesn't happen when a sprite is hidden. i can just make a blank sprite (no color) and then scale it how i need