Discuss Scratch

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!
ThatIdiotRocc
Scratcher
8 posts

Coding an if touching

I don't follow.
Cyethawne
Scratcher
80 posts

Coding an if touching

Pixilized wrote:

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!

ThatIdiotRocc wrote:

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] ?> then
switch costume to [ GAME OVER PLAY AGAIN?]
end
after the switch costume, I inserted a restarting code but its irrelevant to this topic I think

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?)

Last edited by Pixilized (April 14, 2024 15:06:29)

Cyethawne
Scratcher
80 posts

Coding an if touching

Pixilized wrote:

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?)
Oh dang. i ddnt realize fsr it was in the border place only… don't ask how lol

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

Pixilized wrote:

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

Pixilized wrote:

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]
if <touching [BORDER v]?> then
go to x:(271) y:(-116)
end
And the if should be in a forever loop.
Cyethawne
Scratcher
80 posts

Coding an if touching

Pixilized wrote:

In the character sprite, there was this script:
when I receive [start v]
if <touching [BORDER v]?> then
go to x:(271) y:(-116)
end
And the if should be in a forever loop.
Ohh okay. I'll do that
Cyethawne
Scratcher
80 posts

Coding an if touching

So

Pixilized wrote:

In the character sprite, there was this script:
when I receive [start v]
if <touching [BORDER v]?> then
go to x:(271) y:(-116)
end
And the if should be in a forever loop.
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.

Last edited by Cyethawne (April 15, 2024 14:00:47)

Pixilized
Scratcher
100+ posts

Coding an if touching

Ctrl Z, maybe?
Cyethawne
Scratcher
80 posts

Coding an if touching

Pixilized wrote:

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

Pixilized wrote:

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
Pixilized
Scratcher
100+ posts

Coding an if touching

Ahh… maybe make backups this time?
Cyethawne
Scratcher
80 posts

Coding an if touching

Pixilized wrote:

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.

Powered by DjangoBB