Discuss Scratch
- Discussion Forums
- » 日本語
- » 意外と知られていないテクニック集
- inoking
-
Scratcher
1000+ posts
意外と知られていないテクニック集
根拠(検証プロジェクトなど)をお願いします。<(#000000)色に触れた>よりも<(すぷらいと v)に触れた>のほうが検知が早い。
プラットフォーマーとかで使える。
- gyakuhonyakusss2
-
Scratcher
100+ posts
意外と知られていないテクニック集
作ってみました。何が言えるかはわかりませんが。。
Last edited by gyakuhonyakusss2 (July 4, 2025 10:54:31)
- inoking
-
Scratcher
1000+ posts
意外と知られていないテクニック集
ちょっとこのトピックの対象を超えますが
スプライトに触れた、色に触れた のソースコードを確認しました。
ざっと見た感じ、スプライトに触れた は対象のスプライト座標枠内に限定してチェックしており(まあ当たり前)
このために 色に触れた より速くなっているようです。
https://github.com/scratchfoundation/scratch-vm/blob/develop/src/blocks/scratch3_sensing.js#L175
の2つからたどって、
https://github.com/scratchfoundation/scratch-vm/blob/develop/src/sprites/rendered-target.js#L743
と
https://github.com/scratchfoundation/scratch-vm/blob/develop/src/sprites/rendered-target.js#L812
その先は
https://github.com/scratchfoundation/scratch-render/blob/develop/src/RenderWebGL.js#L967
https://github.com/scratchfoundation/scratch-render/blob/develop/src/RenderWebGL.js#L775
スプライトに触れた、色に触れた のソースコードを確認しました。
ざっと見た感じ、スプライトに触れた は対象のスプライト座標枠内に限定してチェックしており(まあ当たり前)
このために 色に触れた より速くなっているようです。
https://github.com/scratchfoundation/scratch-vm/blob/develop/src/blocks/scratch3_sensing.js#L175
touchingObject (args, util) { return util.target.isTouchingObject(args.TOUCHINGOBJECTMENU); } touchingColor (args, util) { const color = Cast.toRgbColorList(args.COLOR); return util.target.isTouchingColor(color); }
https://github.com/scratchfoundation/scratch-vm/blob/develop/src/sprites/rendered-target.js#L743
isTouchingObject (requestedObject) { if (requestedObject === '_mouse_') { if (!this.runtime.ioDevices.mouse) return false; const mouseX = this.runtime.ioDevices.mouse.getClientX(); const mouseY = this.runtime.ioDevices.mouse.getClientY(); return this.isTouchingPoint(mouseX, mouseY); } else if (requestedObject === '_edge_') { return this.isTouchingEdge(); } return this.isTouchingSprite(requestedObject); } : isTouchingSprite (spriteName) { spriteName = Cast.toString(spriteName); const firstClone = this.runtime.getSpriteTargetByName(spriteName); if (!firstClone || !this.renderer) { return false; } // Filter out dragging targets. This means a sprite that is being dragged // can detect other sprites using touching <sprite>, but cannot be detected // by other sprites while it is being dragged. This matches Scratch 2.0 behavior. const drawableCandidates = firstClone.sprite.clones.filter(clone => !clone.dragging) .map(clone => clone.drawableID); return this.renderer.isTouchingDrawables( this.drawableID, drawableCandidates); }
https://github.com/scratchfoundation/scratch-vm/blob/develop/src/sprites/rendered-target.js#L812
isTouchingColor (rgb) { if (this.renderer) { return this.renderer.isTouchingColor(this.drawableID, rgb); } return false; }
https://github.com/scratchfoundation/scratch-render/blob/develop/src/RenderWebGL.js#L967
/** * Check if a particular Drawable is touching any in a set of Drawables. * @param {int} drawableID The ID of the Drawable to check. * @param {?Array<int>} candidateIDs The Drawable IDs to check, otherwise all visible drawables in the renderer * @returns {boolean} True if the Drawable is touching one of candidateIDs. */ isTouchingDrawables (drawableID, candidateIDs = this._drawList) {
/** * Check if a particular Drawable is touching a particular color. * Unlike touching drawable, if the "tester" is invisble, we will still test. * @param {int} drawableID The ID of the Drawable to check. * @param {Array<int>} color3b Test if the Drawable is touching this color. * @param {Array<int>} [mask3b] Optionally mask the check to this part of Drawable. * @returns {boolean} True iff the Drawable is touching the color. */ isTouchingColor (drawableID, color3b, mask3b) {
Last edited by inoking (July 6, 2025 07:37:14)
- inoking
-
Scratcher
1000+ posts
意外と知られていないテクニック集
ちょっとこのトピックの対象を超えますがすみません、
スプライトに触れた、色に触れた のソースコードを確認しました。
ざっと見た感じ、スプライトに触れた は対象のスプライト座標枠内に限定してチェックしており(まあ当たり前)
このために 色に触れた より速くなっているようです。
よく考えたらその理由はちょっと違う気がしてきました。
もう少し調べます。
- yuito2013
-
Scratcher
100+ posts
意外と知られていないテクニック集
((背景の [番号 v]::looks)はなぜか、周りに赤い枠があり、
[scratchblocks](/ \は追加であり、/ \の中のカッコが余分である
((背景の [番号 v]::looks/)\
[/scratchblocks]
(背景の [番号 v]::looksこうするためには、
[scratchblocks]
(背景の [番号 v]::looks
[/scratchblocks]
- mochimochiyuu
-
Scratcher
32 posts
意外と知られていないテクニック集
#4489
そりゃそうでしょ。
最初の分では
()を取らないと周りに赤いやつがつくのは当たり前。
だって、それって定義ブロックの丸いやつということだから、丸いやつに
そりゃそうでしょ。
最初の分では
((背景の [番号 v]::looks/)括弧がついてしまってる。
()を取らないと周りに赤いやつがつくのは当たり前。
だって、それって定義ブロックの丸いやつということだから、丸いやつに
(背景の [番号 v])が入るのは当たり前。
- r_1000
-
Scratcher
32 posts
意外と知られていないテクニック集
左右上下に動かしたいときに
if <key [d v] pressed?> thenではなくて
change x by (10)
end
change x by ((<key [d v] pressed?> + (<key [a v] pressed?> * (-1))) * (10))みたいにするとブロックがまとまる
- U-Y-Scratch
-
Scratcher
500+ posts
意外と知られていないテクニック集
左右上下に動かしたいときにif <key [d v] pressed?> thenではなくて
change x by (10)
endchange x by ((<key [d v] pressed?> + (<key [a v] pressed?> * (-1))) * (10))みたいにするとブロックがまとまる
(<key [A v] pressed?> * (-1))なんて知らないと思い付かないですよね
- ioqj
-
Scratcher
500+ posts
意外と知られていないテクニック集
正直どうでもいい話ですがchange x by ((<key [d v] pressed?> + (<key [a v] pressed?> * (-1))) * (10))みたいにするとブロックがまとまる
それだとブロックが少し余計に多いです。
change x by ((<key [d v] pressed?> - <key [a v] pressed?>) * (10))この方がブロック数が少ないです。
- maikurakun_828
-
Scratcher
100+ posts
意外と知られていないテクニック集
プロフィールのコメント欄にコメントされたときに、「あなたのプロフィール」を押した。だけど、コメントが読み込まれない!
↓こんなときは
ナビゲーションバー(画面上部のバー)の自分のScratch名を押して「プロフィール」を押そう。そうすると、他のコメントも出てくるけど、早く読み込んでくれる!
(消えてる場合は再読み込みをしよう)
↓こんなときは
ナビゲーションバー(画面上部のバー)の自分のScratch名を押して「プロフィール」を押そう。そうすると、他のコメントも出てくるけど、早く読み込んでくれる!
(消えてる場合は再読み込みをしよう)
- U-Y-Scratch
-
Scratcher
500+ posts
意外と知られていないテクニック集
無駄すぎるテクニック(自分で考えました)
<条件>は<<条件> = [true]>で代用できる。
Last edited by U-Y-Scratch (July 12, 2025 08:47:44)
- mochimochiyuu
-
Scratcher
32 posts
意外と知られていないテクニック集
どうやったら非共有の作品を注目のプロジェクトにできますか?やり方ならあるとは思うけど…
な ぜ や ろ う と し て い る
ほんとに教えて
- mochimochiyuu
-
Scratcher
32 posts
意外と知られていないテクニック集
無駄すぎるテクニック(自分で考えました)いやまあ…使えますけど…<条件>は<<条件> = [true]>で代用できる。
<[] = []>に
<条件>が入るとわかるなら…まあ、有意義…?











