This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-05-29 10:37:10

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Sprite Changing Help

Where is the code that is used to change sprites (E.G from sprite 1 to sprite 2)? The bit that changes the scripting pane.

Also can I use to to change to a sprite of my choice?
E.G Make a new block
[focus on sprite %s]

And finally how can I get a list of all sprites (inc. stage)?
E.G
t1_ self allSpriteNames.


You can now reach me on Twitter @johnnydean1_

Offline

 

#2 2011-05-29 12:06:03

Pecola1
Scratcher
Registered: 2010-09-06
Posts: 1000+

Re: Sprite Changing Help

nextInstanceName has sumthin ta do with it. I can look for the actual code.


If you are reading this, please read to the end, because if you don't you won't know what's at the end. Don't just skip to the end though otherwise you won't be able to read the middle, which is most important. Now you must be wondering why you just read all that, the reason is you may have not noticed something, read it again and see if you notice it this time  smile

Offline

 

#3 2011-05-29 12:06:20

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: Sprite Changing Help

Please


You can now reach me on Twitter @johnnydean1_

Offline

 

#4 2011-05-29 12:08:08

Pecola1
Scratcher
Registered: 2010-09-06
Posts: 1000+

Re: Sprite Changing Help

I think all you need is next instance name. You could be able to edit it so it could say dog 1 dog 2 or anything from there, it depends on what you are doing.

Its ScriptableScratchMorph private/all nextInstanceName

Last edited by Pecola1 (2011-05-29 12:09:01)


If you are reading this, please read to the end, because if you don't you won't know what's at the end. Don't just skip to the end though otherwise you won't be able to read the middle, which is most important. Now you must be wondering why you just read all that, the reason is you may have not noticed something, read it again and see if you notice it this time  smile

Offline

 

#5 2011-05-29 12:09:14

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: Sprite Changing Help

Can you give the location of the method?


You can now reach me on Twitter @johnnydean1_

Offline

 

#6 2011-05-29 12:14:17

Pecola1
Scratcher
Registered: 2010-09-06
Posts: 1000+

Re: Sprite Changing Help

johnnydean1 wrote:

Can you give the location of the method?

Pecola1 wrote:

Its ScriptableScratchMorph private/all nextInstanceName


If you are reading this, please read to the end, because if you don't you won't know what's at the end. Don't just skip to the end though otherwise you won't be able to read the middle, which is most important. Now you must be wondering why you just read all that, the reason is you may have not noticed something, read it again and see if you notice it this time  smile

Offline

 

#7 2011-05-29 12:17:08

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: Sprite Changing Help

Woops didn't see that...


You can now reach me on Twitter @johnnydean1_

Offline

 

#8 2011-05-29 12:20:46

Pecola1
Scratcher
Registered: 2010-09-06
Posts: 1000+

Re: Sprite Changing Help

When you say list of all sprites, you mean for the dropdown right? You have to go to ScratchBlocks -> SpriteArgMorph -> event handling -> presentMenu

add somwhere after the t4 _ CustomMenu new.

t2 = #yourBlocksSelector
        ifTrue: [t4 add: 'Stage' localized asUTF8 action: t1 workPane]

Last edited by Pecola1 (2011-05-29 12:21:49)


If you are reading this, please read to the end, because if you don't you won't know what's at the end. Don't just skip to the end though otherwise you won't be able to read the middle, which is most important. Now you must be wondering why you just read all that, the reason is you may have not noticed something, read it again and see if you notice it this time  smile

Offline

 

#9 2011-05-29 12:22:09

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: Sprite Changing Help

I want a block that is:
[change scripting pane to %sprite ]

nextInstanceName is the name of a default sprite...


You can now reach me on Twitter @johnnydean1_

Offline

 

#10 2011-05-29 12:24:56

Pecola1
Scratcher
Registered: 2010-09-06
Posts: 1000+

Re: Sprite Changing Help

johnnydean1 wrote:

I want a block that is:
[change scripting pane to %sprite ]

nextInstanceName is the name of a default sprite...

Oh.... thats a little different isn't it. LOL I can get that i think let me see...


If you are reading this, please read to the end, because if you don't you won't know what's at the end. Don't just skip to the end though otherwise you won't be able to read the middle, which is most important. Now you must be wondering why you just read all that, the reason is you may have not noticed something, read it again and see if you notice it this time  smile

Offline

 

#11 2011-05-29 12:28:16

Pecola1
Scratcher
Registered: 2010-09-06
Posts: 1000+

Re: Sprite Changing Help

Hmmm... I can get it to change what block category it focuses on but not the sprite I can keep looking.


If you are reading this, please read to the end, because if you don't you won't know what's at the end. Don't just skip to the end though otherwise you won't be able to read the middle, which is most important. Now you must be wondering why you just read all that, the reason is you may have not noticed something, read it again and see if you notice it this time  smile

Offline

 

#12 2011-05-29 13:59:16

TheSuccessor
Scratcher
Registered: 2010-04-23
Posts: 1000+

Re: Sprite Changing Help

Try this. It goes in ScriptableScratchMorph.

Code:

switchTo: sprite
    | scratchFrame |
    scratchFrame _ (self ownerThatIsA: ScratchFrameMorph)
                ifNil: [self ownerThatIsA: OffscreenWorldMorph frame].
    scratchFrame viewerPane target: sprite.
    sprite viewBlocksAndScripts

/* No comment */

Offline

 

#13 2011-05-30 03:01:04

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: Sprite Changing Help

TheSuccessor wrote:

Try this. It goes in ScriptableScratchMorph.

Code:

switchTo: sprite
    | scratchFrame |
    scratchFrame _ (self ownerThatIsA: ScratchFrameMorph)
                ifNil: [self ownerThatIsA: OffscreenWorldMorph frame].
    scratchFrame viewerPane target: sprite.
    sprite viewBlocksAndScripts

Nope...


You can now reach me on Twitter @johnnydean1_

Offline

 

#14 2011-05-30 06:07:21

TheSuccessor
Scratcher
Registered: 2010-04-23
Posts: 1000+

Re: Sprite Changing Help

Maybe this?

Code:

switchTo: t1
    | t2 t3 |
    t2 _ (self ownerThatIsA: ScratchFrameMorph)
                ifNil: [(self ownerThatIsA: OffscreenWorldMorph) frame].
    t3 _ self coerceSpriteArg: t1.
    t2 viewerPane target: t3.
    t3 viewBlocksAndScripts

Blockspec:
('change scripting pane to %m' #- #switchTo:) (take out # symbols if using source).

Last edited by TheSuccessor (2011-05-30 06:08:24)


/* No comment */

Offline

 

#15 2011-05-30 06:44:22

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: Sprite Changing Help

It works... Thanks!


You can now reach me on Twitter @johnnydean1_

Offline

 

#16 2011-05-30 08:42:47

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: Sprite Changing Help

TheSuccessor wrote:

Maybe this?

Code:

switchTo: t1
    | t2 t3 |
    t2 _ (self ownerThatIsA: ScratchFrameMorph)
                ifNil: [(self ownerThatIsA: OffscreenWorldMorph) frame].
    t3 _ self coerceSpriteArg: t1.
    t2 viewerPane target: t3.
    t3 viewBlocksAndScripts

Blockspec:
('change scripting pane to %m' #- #switchTo:) (take out # symbols if using source).

What about the stage, that does not work...


You can now reach me on Twitter @johnnydean1_

Offline

 

Board footer