(I'm going on vacation soon. I may not see your answer until July 19th.)
Is there anyway to set a variable to the height or width of a sprite's current costume? For example, the scratch cat is 95x111. In any sprite or background, is there a way to get a block's variable (say, t2) to return these values? Also, is there a way to reference to size % of a sprite?

Offline
In Looks category, you have 3 blocks related to the size of the sprite:
- change size by %n
- set size to %n%
- size (reporter)
They are defined in ScratchSpriteMorph's blockSpecs class method. You may want to take a look at the methods associated with those blocks:
- ScratchSpriteMorph>>changeSizeBy:
- ScratchSpriteMorph>>setSizeTo:
- ScratchSpriteMorph>>scale
They all use ScratchSpriteMorph's instance variable "scalePoint". Maybe you can get something out of it.
Offline
The "super initialize" send in ScratchSpriteMorph>>initialize assigns the result of ScratchSpriteMorph>>defaultImageMedia to its costume. This method returns an ImageMedia:
"I am a Scratch image media object. I hold a still image that can be used as the costume for a Scratch object."
Maybe you'll want to check that out too.
Offline
Okay, I've figured this out:
ChangeSizeBy: calls SetSizeTo:, which in turn calls ScalePoint:. ScalePoint: sets ScalePoint (no colon) to t1, its argument. Scale then returns (100 * scalePoint x) rounded.
So that's how size works. The question is: how can I reference Sprite1's Scalepoint variable in all sprites, and the background? And what about the size of the costume?

Offline
The default costume is loaded into the form of an ImageMedia in ScratchFrameMorph's defaultSprite class method. The form is initialized in ImageMedia>>initalize with an instance of Form class. The form class has instance variables such as width and height which you should be able to use somehow.
Offline
Baderous wrote:
The default costume is loaded into the form of an ImageMedia in ScratchFrameMorph's defaultSprite class method. The form is initialized in ImageMedia>>initalize with an instance of Form class. The form class has instance variables such as width and height which you should be able to use somehow.
So let me get this straight: Now I'm at Graphics-Display Objects > Form > accessing. The variables 'height' and 'width' seem to be located there. You think they refer to the height/width of the current costume?

Offline
Baderous wrote:
Yes.
It works!
<when green flag clicked>
<forever>
<say[ THANK YOU!!!!
<end>

Offline
I think we should put these in the library. Should we say it's your block? It kinda is...

Offline
Baderous wrote:
That's ok for me.
![]()
But I made the blockspec... *starts whining*
...Just kidding. I'll say you did most of it.

Offline
Baderous wrote:
Just say it's our block (I read "our" instead of "your", only noticed after posting).
Nah, I barely did anything. See my post:
http://scratch.mit.edu/forums/viewtopic … 81#p819081

Offline
Just to let you know that the blocks you/we created were more simpler than I thought, and as I think you haven't realized what you've done, I feel like I should explain you. The selector you defined for the reporter block "width" has the name "width" and, as you said, there's no new code. That's because the method that you're calling is not the width selector from the Form class, but Morph>>width. This method is inherited by ScratchSpriteMorph because this class is subclass of Morph and, as such, you needn't write new code. What this method does is call "bounds width", which returns the width of the bounds instance variable of the class Morph. This "bounds" is nothing more than a rectangle that encloses the morph (in this case, the sprite).
So, after all, it was simpler than we thought.
Offline
Baderous wrote:
Just to let you know that the blocks you/we created were more simpler than I thought, and as I think you haven't realized what you've done, I feel like I should explain you. The selector you defined for the reporter block "width" has the name "width" and, as you said, there's no new code. That's because the method that you're calling is not the width selector from the Form class, but Morph>>width. This method is inherited by ScratchSpriteMorph because this class is subclass of Morph and, as such, you needn't write new code. What this method does is call "bounds width", which returns the width of the bounds instance variable of the class Morph. This "bounds" is nothing more than a rectangle that encloses the morph (in this case, the sprite).
So, after all, it was simpler than we thought.![]()
Hey, it works. The more simple it is, the better. Besides, we were the first to do it (or at least officially make the block).

Offline