Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Coding an if touching
- Cyethawne
-
Scratcher
80 posts
Coding an if touching
How do I code if touching through different sprites? For example, one sprite features the border but another has the image the border is bordering. So how do I code the character of the game for an ‘'if touching border then’' across sprites
- Pixilized
-
Scratcher
100+ posts
Coding an if touching
I don’t know what you mean. Could you please elaborate more, or explain a your problem in a different way? I’d like to help if I can!
- Cyethawne
-
Scratcher
80 posts
Coding an if touching
I don’t know what you mean. Could you please elaborate more, or explain a your problem in a different way? I’d like to help if I can!
I don't follow.Okay
In the particular project I'm referring to there's a maze and I want to code the character in the game so that it cant walk off the maze platform. As a result I made another sprite called border and coded it this way:
if <touching [ BORDER] ?> thenafter the switch costume, I inserted a restarting code but its irrelevant to this topic I think
switch costume to [ GAME OVER PLAY AGAIN?]
end
However, this code hasn't worked. Do you guys have any ideas?
Project link: https://scratch.mit.edu/projects/961877686/
Last edited by Cyethawne (April 14, 2024 15:00:05)
- Pixilized
-
Scratcher
100+ posts
Coding an if touching
I didn’t have time to analyze all the code, but from what I can tell you need to put the if block in a forever loop.
If this doesn’t work, let me know and I’ll check the code again. (Side note: why do you have a “touching border” script in the border sprite?)
If this doesn’t work, let me know and I’ll check the code again. (Side note: why do you have a “touching border” script in the border sprite?)
Last edited by Pixilized (April 14, 2024 15:06:29)
- Cyethawne
-
Scratcher
80 posts
Coding an if touching
I didn’t have time to analyze all the code, but from what I can tell you need to put the if block in a forever loop.Oh dang. i ddnt realize fsr it was in the border place only… don't ask how lol
If this doesn’t work, let me know and I’ll check the code again. (Side note: why do you have a “touching border” script in the border sprite?)
Yeah, thanks ill check that out now
- Pixilized
-
Scratcher
100+ posts
Coding an if touching
It’s not in the border place only. There’s also a touching border script in the player sprite. That’s the script I believe needs to be in a forever loop.
- Cyethawne
-
Scratcher
80 posts
Coding an if touching
It’s not in the border place only. There’s also a touching border script in the player sprite. That’s the script I believe needs to be in a forever loop.You misunderstand me. I meant that I didn't realize I hadn't put it in the character sprite.
- Pixilized
-
Scratcher
100+ posts
Coding an if touching
There was one in the character sprite. It was under a broadcast hat block. There was just also one in the border sprite.
- Cyethawne
-
Scratcher
80 posts
Coding an if touching
There was one in the character sprite. It was under a broadcast hat block. There was just also one in the border sprite.Oh, what? Im confused sorry
- Pixilized
-
Scratcher
100+ posts
Coding an if touching
In the character sprite, there was this script:
when I receive [start v]And the if should be in a forever loop.
if <touching [BORDER v]?> then
go to x:(271) y:(-116)
end
- Cyethawne
-
Scratcher
80 posts
Coding an if touching
In the character sprite, there was this script:Ohh okay. I'll do thatwhen I receive [start v]And the if should be in a forever loop.
if <touching [BORDER v]?> then
go to x:(271) y:(-116)
end
- Cyethawne
-
Scratcher
80 posts
Coding an if touching
So
In the character sprite, there was this script:sorry to everyone whos been helping me with this. I accidentally deleted all the code for the character sprites and it might take me some days to get back on track.when I receive [start v]And the if should be in a forever loop.
if <touching [BORDER v]?> then
go to x:(271) y:(-116)
end
Last edited by Cyethawne (April 15, 2024 14:00:47)
- Cyethawne
-
Scratcher
80 posts
Coding an if touching
Ctrl Z, maybe?I saved the delete. I'm crying ;-; my assignment is sooooooooooo late already
- Pixilized
-
Scratcher
100+ posts
Coding an if touching
Oh no. Do you have any files of older versions saved?
- Cyethawne
-
Scratcher
80 posts
Coding an if touching
Oh no. Do you have any files of older versions saved?yeah but its so old it'll be reversing my work. I am beginning to work on redoing it
- Cyethawne
-
Scratcher
80 posts
Coding an if touching
Ahh… maybe make backups this time?Yes, Iv redone it and made a backup so you could add whatever you intended now?
- Pixilized
-
Scratcher
100+ posts
Coding an if touching
It's just the thing I said earlier, putting the if in a forever loop.
- Discussion Forums
- » Help with Scripts
-
» Coding an if touching


