question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Touching sprite" block behavior with clones?

See original GitHub issue

In Scratch, the “touching (sprite)” block will return true if the current sprite is touching the other sprite or any of its clones. In scratch-js, it only returns true if it’s touching the original sprite.

I think a good solution would be to retain the current behavior if you pass a sprite instance to touching(), but to use Scratch’s behavior if you pass the sprite’s base class. I’d like to get your opinion on it.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

2reactions
towerofnixcommented, Dec 29, 2019

I’m pretty strongly in favor of the first idea there! It lets you easily access a sprite and its clones together, which, thanks to treating sprites as first-class objects, is good for more complex programming concepts not easily possible in Scratch.

In order to match Scratch behavior without introducing more complex syntax, we would probably want to make andClones return the sprite as well as any of the clones made of it, and any clones of those clones themselves. (But, if you do (a clone).andClones(), not clones of the parent/original sprite, IMO, since if you wanted to do that you’d just access the original object directly (this.sprites.whatever).)

0reactions
PullJoshcommented, Dec 30, 2019
  • Allow passing an array of instances. Could also give sprites a .andClones() method so you can do if (this.touching(this.sprites.sprite2.andClones())

.andClones() now exists (see #32), so we can move ahead with this.

There are basically two things that need to happen:

  1. Update the touching block to accept an array of instances (or a single instance)
  2. Update sb-edit to include .andClones() in all uses of the touching block
Read more comments on GitHub >

github_iconTop Results From Across the Web

"Touching sprite" block behavior with clones? #25 - GitHub
In Scratch, the "touching (sprite)" block will return true if the current sprite is touching the other sprite or any of its clones....
Read more >
Touching Sprite block returns true for clones - Discuss Scratch
I'm making a multiplayer kart battle mode in a game, and you'd have to use items to deal damage. The items for each...
Read more >
Cloning - Scratch Wiki
Cloning is a feature that allows a sprite to create a copy of itself while the project is running. Each clone has the...
Read more >
How do I make an "If player Touching <costume> of clone ...
But, I tried the "costume #/name of sprite" block but it doesn't work, It just make the same action over and over. Here's...
Read more >
CS 105 | exercise13
Now that we have the clone behavior sorted, we can return to the main Ground script and add some blocks to spawn new...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found