rajababu wrote:
Is there a way to pass Sprite's reference to a block created using BYOB?
Such as the sprites name?
Offline
hmm i dont realy know BYOB but ill have a loook
Offline
rajababu wrote:
Is there a way to pass Sprite's reference to a block created using BYOB?
I'm not sure I completely understand your question, but maybe what you're looking for is the [<thing> OF <sprite>] block in the
sensing menu. The first dropdown will include all the local variables and local methods of the sprite you choose in the second dropdown.
What doesn't seem to work, though, is dropping a variable onto the second dropdown; that makes the first dropdown not work. We'll put it on the list of things to think about, but probably not until 3.1.
Offline
Let me try to explain a little more
My understanding of a procedure is to reduce the repetition of the code.... say for example
I have 20 sprites.
I want to make the x and y position for two sprites say Sprite1 and Sprite11 same if the two sprites are touching each other.
The same should be true between
Sprite2 and Sprite12
Sprite3 and Sprite13
Sprite4 and Sprite14
.
.
and so on till Sprite10 and Sprite20.
So rather than repeating the code in each Sprite I want to write a procedure which will do this. I need an option to get and set the attributes of a Sprite reference passed to the procedure.
Offline
rajababu wrote:
I want to make the x and y position for two sprites say Sprite1 and Sprite11 same if the two sprites are touching each other...
Okay, this is a little bit of a kludge but you can do it...
First of all, the procedure to do the work will be global -- you write it once and be sure "for all sprites" is checked; it's the default, so you just have to refrain from changing it.
Let's say sprite11 is going to move to sprite1's position. Then your block is called, say, CHECKTOUCH, and it has three inputs: TESTER, which is declared of type Predicate, and XPOS and YPOS, which are of type Reporter. The code of CHECKTOUCH is:
FOREVER IF [CALL <tester>]
SET X TO [CALL <xpos>]
SET Y TO [CALL <ypos>]
And then you have a green-flag script in Sprite11 that says
CHECKTOUCH [THE [<TOUCHING? <sprite1>] BLOCK]
[THE [<x position> OF <sprite1>] BLOCK]
[THE [<y position> OF <sprite1>] BLOCK]
In Sprite12 you have
CHECKTOUCH [THE [<TOUCHING? <sprite2>] BLOCK]
[THE [<x position> OF <sprite2>] BLOCK]
[THE [<y position> OF <sprite2>] BLOCK]
Now, what you really want is to have
SET <partner> TO <sprite2>
and then be able to use <partner> in the CHECKTOUCH script. (I know you know that's what you want because of the title you gave this forum!) First class sprites are definitely on our agenda, but short of a miracle they won't be in BYOB 3.0. It's high on our wish list for 3.1, though.
Offline