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

How do when i detect a sprite (using spcol and sphitsp) how do when thay collide the moving sprite stops moving?

Root / Programming Questions / [.]

zagg2000Created:
yeah, what i sed.

Do you already have movement code setup? for spcol you need(spr#,u,v,w,h,true,255)//255 being the opacity of the mask i believe... so with that you would need to set up spcol for your "player" and your "tile/enemy" spcol (1,u,v,w,h,true,255)//one being your player spcol (2,u,v,w,h,true,255)//being your colliding tile now these have to be set up before sphit! // visit smilebasics website instruction manual for complete list of functions or use the 3ds manual so when you finally get to sphit the function asks for spr#1 and spr#2 so for moving left as an example i wrote
if sphit(1,2) then px=px'if we are touching then px = its current x coordinates
if !sphit(1,2)then px=-1 'minus the x coordinates and moves us to the left
spofs(0,px,py,0)
vsync1
but this is an bad example because sphit also wants spcolvec, but this will get you results and thats one way to do it

Thanks! i'll see if this works.

yeah i have movement code, and the collision code, but i need to know how to stop the character when they simply collide. Note, im using STICK OUT SX,SY as my movement code.

TL;DR: IF NOT <COLLIDE BOOLEAN> THEN <MOVEMENT CODE> Then put the actual movement code (SPOFS OUT blah blah) in an if loop that only fires when the sprite is not colliding. So if the sprite is not colliding, they will move, but if they are colliding, they will stay where they were before collision. In theory, this should work if only one sprite moves. EDIT: It works with some tweaking, you need to have a backup of the character sprite positions of last frame in case the player is stuck. Key is 93433XRX. EDIT2: Making a platform engine with this