トピック
Clayton DarkClay88

How do I program touching?

I need this to finish my game I'm making right now. I know it involves TOUCH STTM,TX,TY but Idk how to use it.
6そうだね
プレイ済み
返信[1]
親投稿
Oscar PwnageBlock
STTM is how long the screen has been touched. It will be 0 if the screen is not being touched. The time it returns is in hundredths seconds, I think. TX and TY simply return the position of the screen that is being touched, or the last touched if the user is no longer touching the screen. You'll probably want to place TOUCH OUT TS,TX,TY inside your main game loop to get touch info constantly.
0そうだね
プレイ済み
返信[2]
親投稿
Clayton DarkClay88
Two questions. 1. The STTM is how long you have to press the screen? 2. The TX,TY is where I need to tap to make something happen?
0そうだね
プレイ済み
返信[3]
親投稿
Oscar PwnageBlock
I suppose you could put it that way.
0そうだね
プレイ済み
返信[4]
親投稿
Clayton DarkClay88
How would I make it so if I tap anywhere on the screen, a sprite will set?
0そうだね
プレイ済み
返信[5]
親投稿
Oscar PwnageBlock
Well, since we know STTM tells us how long the touch screen has been touched, and that STTM is 0 if there is no touch, you could do... TOUCH OUT STTM,TX,TY IF STTM==1 THEN SPSET ?,? ...to set a sprite the very moment the touch screen is touched.
0そうだね
プレイ済み
返信[6]
親投稿
Clayton DarkClay88
Interesting. I'm definitely gonna experiment this a lot like I did with some AI's. Thanks a ton!
0そうだね
プレイ済み
返信[7]
親投稿
Clayton DarkClay88
How would I program so when I tap the screen in a certain location, the sprite will appear where I tapped.
0そうだね
プレイ済み
返信[8]
親投稿
Oscar PwnageBlock
Simple! Use TX and TY to offset your sprite accordingly. IF TS THEN 'AS LONG AS THE USER IS TOUCHING SPOFS ?,TX,TY 'LOCATE THE SPRITE AT TX, TY ENDIF
0そうだね
プレイ済み
返信[9]
親投稿
Clayton DarkClay88
So it's basically saying, If STTM is 1 then the sprite should follow the touch. Its a little off but I made it to follow me. :)
0そうだね
プレイ済み
返信[10]
親投稿
Clayton DarkClay88
And is there a certain collision code for touching a sprite? So like, when I tap a sprite it makes a sound?
0そうだね
プレイ済み
返信[11]
親投稿
Oscar PwnageBlock
That's a bit harder, but doable. Simply check if the touch coordinates match the coordinates of the sprite. If they do, play a sound. IF STTM==1 THEN SPOFS <Management#> OUT X,Y IF ABS(TX-X)<16 && ABS(TY-Y)<16 THEN BEEP ENDIF The above conditional checks if the distances between the touch's coordinates and the sprite's coordinates were within the sprites area.
0そうだね
プレイ済み
返信[12]
親投稿
Oscar PwnageBlock
Of course, this is assuming the sprite's size is 16x16px and its home is 0,0.
0そうだね
プレイ済み
返信[13]
親投稿
Clayton DarkClay88
Interesting! I will experiment this without a doubt! Thanks so much! (You're included in the credits of my program. :) You should check it out)
0そうだね
プレイ済み