I read the post by billyedward, but I still cant get it to work. I want to add a block that says "if touching {object} bounce"
This is the code, i got it from the block library but I have no idea how or where to add it.
Blockspec:
('if touching %m bounce' #- #bounceOffSprite:)
code:
bounceOffSprite: aName
| sprite oldDir |
sprite _ self coerceSpriteArg: aName.
(self touching: sprite)
ifFalse: [^ self].
oldDir _ self heading.
self pointTowards: sprite.
self turnRight: self heading - oldDir + 180.
[self touching: sprite]
whileTrue: [self forward: 1]
Offline
Assuming you know how to get into the browser and navigate, the place is: for the blockspecs: Scratch_Objects/ScratchSpriteMorph/block specs/blockSpecs then click the class button for the code once following the place above, click the instance button.
Offline
I figured out where to insert the blockspec, but I have no clue where to insert the code. Please be detailed.
Blockspec:
('if touching %m bounce' #- #bounceOffSprite:)
code:
bounceOffSprite: aName
| sprite oldDir |
sprite _ self coerceSpriteArg: aName.
(self touching: sprite)
ifFalse: [^ self].
oldDir _ self heading.
self pointTowards: sprite.
self turnRight: self heading - oldDir + 180.
[self touching: sprite]
whileTrue: [self forward: 1]
Offline
Offline
I figured out where to add the blockspec, but not the code
Offline
sorry. I didn't know I could reply to my own posts untill just now.
Offline
The code is at: Scratch-Objects > ScriptableSpriteMorph (or the ones that have "Scriptable" in their names) > Instance > [Category] Ops > Enter the code (Don't listen to the capitalization).
Offline