Difference between revisions of "Script Classes for Adventure Games/View Class"
(10 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
Chapter: | Chapter: | ||
[[Script Classes for Adventure Games/Introduction|1]] | | [[Script Classes for Adventure Games/Introduction|1]] | | ||
− | [[Script Classes for Adventure Games/RootObj|2]] | | + | [[Script Classes for Adventure Games/RootObj Class|2]] | |
− | [[Script Classes for Adventure Games/Object|3]] | | + | [[Script Classes for Adventure Games/Object Class|3]] | |
− | [[Script Classes for Adventure Games/Collection|4]] | | + | [[Script Classes for Adventure Games/Collection Class|4]] | |
− | [[Script Classes for Adventure Games/ | + | [[Script Classes for Adventure Games/Script Class|5]] | |
− | [[Script Classes for Adventure Games/ | + | [[Script Classes for Adventure Games/Timer Class|6]] | |
− | [[Script Classes for Adventure Games/ | + | [[Script Classes for Adventure Games/Feature Class|7]] | |
− | [[Script Classes for Adventure Games/ | + | [[Script Classes for Adventure Games/View Class|8]] | |
− | [[Script Classes for Adventure Games/ | + | [[Script Classes for Adventure Games/PicView Class|9]] | |
− | [[Script Classes for Adventure Games/ | + | [[Script Classes for Adventure Games/Cycling Classes|10]] | |
− | [[Script Classes for Adventure Games/ | + | [[Script Classes for Adventure Games/Motion Classes|11]] | |
− | [[Script Classes for Adventure Games/ | + | [[Script Classes for Adventure Games/Avoider Class|12]] | |
− | [[Script Classes for Adventure Games/ | + | [[Script Classes for Adventure Games/Event Class|13]] | |
− | [[Script Classes for Adventure Games/ | + | [[Script Classes for Adventure Games/User Class|14]]<br /> |
− | + | [[Script Classes for Adventure Games/Game Class|15]] | | |
− | + | [[Script Classes for Adventure Games/Locale Class|16]] | | |
− | + | [[Script Classes for Adventure Games/Region Class|17]] | | |
− | + | [[Script Classes for Adventure Games/Room Class|18]] | | |
− | + | [[Script Classes for Adventure Games/Timer2 Class|19]] | | |
− | + | [[Script Classes for Adventure Games/InvItem Class|20]] | | |
− | + | [[Script Classes for Adventure Games/Block Class|21]] | | |
− | + | [[Script Classes for Adventure Games/Cage Class|22]] | | |
− | + | [[Script Classes for Adventure Games/Sound Class|23]] | | |
− | + | [[Script Classes for Adventure Games/StatusLine Class|24]] | | |
− | + | [[Script Classes for Adventure Games/File Class|25]] | | |
− | + | [[Script Classes for Adventure Games/Code Class|26]] | | |
− | + | [[Script Classes for Adventure Games/Global Variables|27]] | | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | [[Script Classes for Adventure Games/Game| | ||
− | [[Script Classes for Adventure Games/Locale| | ||
− | [[Script Classes for Adventure Games/Region| | ||
− | [[Script Classes for Adventure Games/Room| | ||
− | [[Script Classes for Adventure Games/Timer2| | ||
− | |||
− | [[Script Classes for Adventure Games/InvItem| | ||
− | [[Script Classes for Adventure Games/Block| | ||
− | [[Script Classes for Adventure Games/Cage| | ||
− | [[Script Classes for Adventure Games/Sound| | ||
− | [[Script Classes for Adventure Games/StatusLine| | ||
− | [[Script Classes for Adventure Games/File| | ||
− | [[Script Classes for Adventure Games/Code| | ||
− | [[Script Classes for Adventure Games/Global Variables| | ||
[[Script Classes for Adventure Games/Index|Index]] | [[Script Classes for Adventure Games/Index|Index]] | ||
</div><br /> | </div><br /> | ||
− | <div align="center"><span style="font-size: 22pt">View</span><br /> | + | <div align="center"><span style="font-size: 22pt">The View Class</span><br /> |
''Author: [[Jeff Stephenson]]''<br /> | ''Author: [[Jeff Stephenson]]''<br /> | ||
''Date: 5 April 1988''</div> | ''Date: 5 April 1988''</div> | ||
Line 62: | Line 39: | ||
| | ||
− | + | ==<br /> The View Class == | |
+ | |||
+ | The View class contains the minimum functionality to put a visible object on the screen in a reversible manner. Thus, as a View, a particular view, loop, and cel may be drawn on the screen and later erased. A View, however neither cycles (like a Prop) nor moves (like an Actor). | ||
+ | |||
+ | {| | ||
+ | |width= "125"|In file:||actor.sc | ||
+ | |- | ||
+ | |Inherits from:||Feature | ||
+ | |- | ||
+ | |Inherited by:||Prop | ||
+ | |} | ||
+ | |||
+ | ===<br /> Properties === | ||
+ | |||
+ | ====<br /> x ==== | ||
+ | ==== y ==== | ||
+ | <blockquote>The position of the View on the screen.</blockquote> | ||
+ | ==== z ==== | ||
+ | <blockquote>The Views elevation above the ground.</blockquote> | ||
+ | |||
+ | ====<br /> view ==== | ||
+ | <blockquote>The number of the View's current view.</blockquote> | ||
+ | |||
+ | ====<br /> loop ==== | ||
+ | <blockquote>The number of the View's current loop.</blockquote> | ||
+ | |||
+ | ====<br /> cel ==== | ||
+ | <blockquote>The number of the View's current cel.</blockquote> | ||
+ | |||
+ | ====<br /> priority ==== | ||
+ | <blockquote>The visual priority of the View.</blockquote> | ||
+ | |||
+ | ====<br /> underBits ==== | ||
+ | <blockquote>A handle to the storage for saving the background of the View.</blockquote> | ||
+ | Don't monkey with this. | ||
+ | |||
+ | ====<br /> nsTop<br />nsLeft<br />nsBottom<br />nsRight ==== | ||
+ | <blockquote>A handle to the storage for saving the background of the View. Don't monkey with this.</blockquote> | ||
+ | |||
+ | ====<br /> nsTop<br />nsLeft<br />nsBottom<br />nsRight ==== | ||
+ | <blockquote>The coordinates of the top, bottom, left, and right edges of the rectangle which encloses the current (nowSeen) cel of the View. Don't monkey with this.</blockquote> | ||
+ | |||
+ | ====<br /> lsTop<br />lsLeft<br />lsBottom<br />lsRight ==== | ||
+ | <blockquote>The lastSeen rectangle for the View — its nowSeen rectangle from the previous animation cycle. Once again, do not touch.</blockquote> | ||
+ | |||
+ | ====<br /> baseRect ==== | ||
+ | |||
+ | <blockquote> | ||
+ | ===== brTop ===== | ||
+ | ===== brLeft ===== | ||
+ | ===== brBottom ===== | ||
+ | ===== brRight ===== | ||
+ | <blockquote>This is the base rectangle (or baseRect) — the rectangle which is considered to be the base of the View for detecting collisions with it. This you can monkey with. The default for the base of a View is a rectangle whose left and right sides are the sides of the nowSeen rectangle, and whose bottom and top are the y coordinate of the View's origin.</blockquote> | ||
+ | </blockquote> | ||
+ | |||
+ | ====<br /> signal ==== | ||
+ | <blockquote>A bit-mapped word for communicating with the kernel animation routines and various methods. Handles start- and stop- updating, fixed priorities, etc. This property should not generally be manipulated directly — the various methods (setPri:, setCel:, stopUpd:, etc.) should be used instead.</blockquote> | ||
+ | |||
+ | ===<br /> Methods === | ||
+ | |||
+ | ====<br /> init ==== | ||
+ | <blockquote>Sets the baseRect of the View and adds it to the cast so that it will be drawn on the screen at its current position.</blockquote> | ||
+ | |||
+ | ====<br /> posn: x y z ==== | ||
+ | <blockquote>Position the View at (x, y, z). Note that the Actual x,y screen coordinates of the object will be x, (y - z). Thus leaving z set to zero will give the traditional x y positioning.</blockquote> | ||
+ | |||
+ | ====<br /> stopUpd ==== | ||
+ | <blockquote>This method sets the signal property to indicate to the interpreter that the image of the object on the screen is not to be updated anymore. This is done to speed up program execution by reducing the number of things to be animated.</blockquote> | ||
+ | |||
+ | ====<br /> startUpd ==== | ||
+ | <blockquote>This undoes a previous stopUpd: of an View.</blockquote> | ||
+ | |||
+ | ====<br /> forceUpd: ==== | ||
+ | <blockquote>This does a one-animation-cycle startUpd: of the View, making a change in the View's view, loop, cel, or position visible, but leaving it in a stopUpd: condition if it was so before.</blockquote> | ||
+ | |||
+ | ====<br /> setPri: [newPri] ==== | ||
+ | <blockquote>This is used to set the priority of a View, based on the value of newPri. Normally, a View is assigned a visual priority by the kernel based on its y position on the screen. If a call to setPri: is made with no newPri specified, the priority is fixed at the current priority of the View. If a value of newPri is specified, the priority is set to that value. A newPri of -1 is used to undo a setPri:, returning control of the priority to the kernel.</blockquote> | ||
+ | |||
+ | ====<br /> setCel: newCel ==== | ||
+ | <blockquote>Sets the cel of the View to newCel.</blockquote> | ||
+ | |||
+ | ====<br /> setLoop: newLoop ==== | ||
+ | <blockquote>Sets the loop of the View to newLoop.</blockquote> | ||
+ | |||
+ | ====<br /> ignoreActors: [n] ==== | ||
+ | <blockquote>If n is absent or TRUE, this allows the View's baseRect to intersect that of Actors. If n is FALSE, the View's baseRect may not intersect that of any Actors — the Actor will collide with it (unless the Actor has itself done an ignoreActors:). The default state of a View is equivalent to ignoreActors:FALSE, i.e. an Actor may not intersect its baseRect.</blockquote> | ||
+ | |||
+ | ====<br /> show ==== | ||
+ | <blockquote>Place a view that has been hidden with hide: back on th screen.</blockquote> | ||
+ | |||
+ | ====<br /> hide ==== | ||
+ | <blockquote>Remove the View from the screen, but not from the cast.</blockquote> | ||
+ | |||
+ | ====<br /> dispose ==== | ||
+ | <blockquote>Tell the kernel to remove the View from the screen. Also set a bit in signal to tell the main animation loop to remove this View from the cast after animation has been completed.</blockquote> | ||
+ | |||
+ | ====<br /> delete ==== | ||
+ | <blockquote>If the proper bit is set in signal, remove this View from the cast and do a (super dispose:).</blockquote> | ||
+ | |||
+ | ====<br /> showStr: where ==== | ||
+ | <blockquote>Format a string describing the View in the storage pointed to by where. This method gives classes inheriting from View the ability to inherit the View part of showSelf: rather than reimplement it.</blockquote> | ||
+ | |||
+ | ====<br /> check: other ==== | ||
+ | <blockquote>This method is used to check for intersection of the baseRect with other. It returns TRUE if the object does not intersect anything. The method for a View or Prop always returns TRUE.</blockquote> | ||
+ | |||
+ | ====<br /> handleEvent: event ==== | ||
+ | <blockquote>All elements of the cast get the handleEvent: message whenever a non-direction event is produced. Only the User's alterEgo is sent direction events.</blockquote> | ||
+ | |||
+ | ====<br /> addToPic ==== | ||
+ | <blockquote>Add this View to the picture in an irreversible manner, then delete the View. The Views important properties are copied into a PicView object created by the system, and the View is then disposed of. Note that this meens that all methods that have been redefined for the View are lost (including, but not limited to the handleEvent method). Thus if you wish to give an addToPic a specialized handleEvent method a PicView object should be used instead.</blockquote> | ||
| | ||
Line 76: | Line 162: | ||
<span style="float: left">[[Script Classes for Adventure Games/Feature Class|< Previous: The Feature Class]]</span> | <span style="float: left">[[Script Classes for Adventure Games/Feature Class|< Previous: The Feature Class]]</span> | ||
− | <span style="float: right">[[Script Classes for Adventure Games/Prop|Next: Prop >]]</span> | + | <span style="float: right">[[Script Classes for Adventure Games/Prop Class|Next: The Prop Class >]]</span> |
| |
Latest revision as of 21:33, 11 December 2015
Chapter:
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
Index
The View Class
The View class contains the minimum functionality to put a visible object on the screen in a reversible manner. Thus, as a View, a particular view, loop, and cel may be drawn on the screen and later erased. A View, however neither cycles (like a Prop) nor moves (like an Actor).
In file: | actor.sc |
Inherits from: | Feature |
Inherited by: | Prop |
Properties
x
y
The position of the View on the screen.
z
The Views elevation above the ground.
view
The number of the View's current view.
loop
The number of the View's current loop.
cel
The number of the View's current cel.
priority
The visual priority of the View.
underBits
A handle to the storage for saving the background of the View.
Don't monkey with this.
nsTop
nsLeft
nsBottom
nsRight
A handle to the storage for saving the background of the View. Don't monkey with this.
nsTop
nsLeft
nsBottom
nsRight
The coordinates of the top, bottom, left, and right edges of the rectangle which encloses the current (nowSeen) cel of the View. Don't monkey with this.
lsTop
lsLeft
lsBottom
lsRight
The lastSeen rectangle for the View — its nowSeen rectangle from the previous animation cycle. Once again, do not touch.
baseRect
brTop
brLeft
brBottom
brRight
This is the base rectangle (or baseRect) — the rectangle which is considered to be the base of the View for detecting collisions with it. This you can monkey with. The default for the base of a View is a rectangle whose left and right sides are the sides of the nowSeen rectangle, and whose bottom and top are the y coordinate of the View's origin.
signal
A bit-mapped word for communicating with the kernel animation routines and various methods. Handles start- and stop- updating, fixed priorities, etc. This property should not generally be manipulated directly — the various methods (setPri:, setCel:, stopUpd:, etc.) should be used instead.
Methods
init
Sets the baseRect of the View and adds it to the cast so that it will be drawn on the screen at its current position.
posn: x y z
Position the View at (x, y, z). Note that the Actual x,y screen coordinates of the object will be x, (y - z). Thus leaving z set to zero will give the traditional x y positioning.
stopUpd
This method sets the signal property to indicate to the interpreter that the image of the object on the screen is not to be updated anymore. This is done to speed up program execution by reducing the number of things to be animated.
startUpd
This undoes a previous stopUpd: of an View.
forceUpd:
This does a one-animation-cycle startUpd: of the View, making a change in the View's view, loop, cel, or position visible, but leaving it in a stopUpd: condition if it was so before.
setPri: [newPri]
This is used to set the priority of a View, based on the value of newPri. Normally, a View is assigned a visual priority by the kernel based on its y position on the screen. If a call to setPri: is made with no newPri specified, the priority is fixed at the current priority of the View. If a value of newPri is specified, the priority is set to that value. A newPri of -1 is used to undo a setPri:, returning control of the priority to the kernel.
setCel: newCel
Sets the cel of the View to newCel.
setLoop: newLoop
Sets the loop of the View to newLoop.
ignoreActors: [n]
If n is absent or TRUE, this allows the View's baseRect to intersect that of Actors. If n is FALSE, the View's baseRect may not intersect that of any Actors — the Actor will collide with it (unless the Actor has itself done an ignoreActors:). The default state of a View is equivalent to ignoreActors:FALSE, i.e. an Actor may not intersect its baseRect.
show
Place a view that has been hidden with hide: back on th screen.
hide
Remove the View from the screen, but not from the cast.
dispose
Tell the kernel to remove the View from the screen. Also set a bit in signal to tell the main animation loop to remove this View from the cast after animation has been completed.
delete
If the proper bit is set in signal, remove this View from the cast and do a (super dispose:).
showStr: where
Format a string describing the View in the storage pointed to by where. This method gives classes inheriting from View the ability to inherit the View part of showSelf: rather than reimplement it.
check: other
This method is used to check for intersection of the baseRect with other. It returns TRUE if the object does not intersect anything. The method for a View or Prop always returns TRUE.
handleEvent: event
All elements of the cast get the handleEvent: message whenever a non-direction event is produced. Only the User's alterEgo is sent direction events.
addToPic
Add this View to the picture in an irreversible manner, then delete the View. The Views important properties are copied into a PicView object created by the system, and the View is then disposed of. Note that this meens that all methods that have been redefined for the View are lost (including, but not limited to the handleEvent method). Thus if you wish to give an addToPic a specialized handleEvent method a PicView object should be used instead.
- Notes
< Previous: The Feature Class Next: The Prop Class >