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

#1 2010-09-28 15:57:40

jkpal
Scratcher
Registered: 2010-06-01
Posts: 11

sprite width and height blocks

The spec for width is:

Code:

 ('width' #r #width)

and the code is:

Code:

width
| t1 |
t1 _ self bounds intersect: bounds.
^ t1 width

The spec for height is:

Code:

 ('height' #r #height)

and the code is:

Code:

height
| t1 |
t1 _ self bounds intersect: bounds.
^ t1 height

the spec for sprite width is:

Code:

('%m width' #r #width:)

the code is:

Code:

width: t1
| t2 |
t2 _ t1 bounds intersect: t1 bounds.
^ t2 width

the spec for sprite height is:

Code:

('%m height' #r #height:)

and the code is:

Code:

height: t1
| t2 |
 t2 _ t1 bounds intersect: t1 bounds.
^ t2 height

.


http://imgur.com/lqxKT.gif http://imgur.com/HgOLi.gif

Offline

 

#2 2010-09-28 19:18:43

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: sprite width and height blocks

I would use "^ t1 filteredForm width". And intersecting bounds with themselves doesn't do anything.


nXIII

Offline

 

Board footer