トピック
Blastoise§ Gastly52

How do you detect sprite collisions? Also, how do you make a sprite move autonomously and randomly?

1そうだね
プレイ済み
返信[1]
親投稿
MathPRG MathProgrammer
Use SPHITSP to find the control number of the sprite collided with. If you are trying to find collision between one specific sprite and many others which aren't so specific, using SPHITSHP(Control Number, First CN, Last CN) works well, where Control Number is the specific sprite's number, and First CN and last CN are the range of numbers to allow returning collision from.
0そうだね
プレイ済み
返信[2]
親投稿
MathPRG MathProgrammer
Also, SPHITSP must either be used in an expression or assigned to a variable. Otherwise it just returns a syntax error, because nothing is being done with it's return value.
0そうだね
プレイ済み
返信[3]
親投稿
Blastoise§ Gastly52
Thanks! Is there anything I have to do with SPCOL and SPCOLVEC?
0そうだね
プレイ済み
返信[4]
親投稿
MathPRG MathProgrammer
Grr, forgot that too! Yes, SPHITSP will not work without caaling SPCOL first. I'd recommend defining SPHOME for a sprite first, then calling SPCOL CN,HX,HY,EX,EY,TRUE - where CN is the Control Number, HX and HY are the NEGATIVE SPHOME offsets, and EX and EXY are the width and height of your sprite. TRUE will adjust the collision for SPSCALE.
0そうだね
プレイ済み
返信[5]
親投稿
MathPRG MathProgrammer
Another mistake! It's EY, not EXY. Also, I mean take the SPHOME offsets and make them negative simply by going (-X) or (-Y) in your parameters for HX and HY. Also, I've never needed SPCOLVEC, I'd only use it if you want a specific speed of collision allowed only.
0そうだね
プレイ済み
返信[6]
親投稿
Blastoise§ Gastly52
Thank you so much!
0そうだね
プレイ済み