Script Classes for Adventure Games/View Class
Author: Jeff Stephenson
- 1 The View Class
- 1.1 Properties
- 1.2 Methods
- 1.2.1 init
- 1.2.2 posn: x y z
- 1.2.3 stopUpd
- 1.2.4 startUpd
- 1.2.5 forceUpd:
- 1.2.6 setPri: [newPri]
- 1.2.7 setCel: newCel
- 1.2.8 setLoop: newLoop
- 1.2.9 ignoreActors: [n]
- 1.2.10 show
- 1.2.11 hide
- 1.2.12 dispose
- 1.2.13 delete
- 1.2.14 showStr: where
- 1.2.15 check: other
- 1.2.16 handleEvent: event
- 1.2.17 addToPic
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).
The position of the View on the screen.
The Views elevation above the ground.
The number of the View's current view.
The number of the View's current loop.
The number of the View's current cel.
The visual priority of the View.
A handle to the storage for saving the background of the View.
Don't monkey with this.
A handle to the storage for saving the background of the View. Don't monkey with this.
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.
The lastSeen rectangle for the View — its nowSeen rectangle from the previous animation cycle. Once again, do not touch.
brRightThis 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.
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.
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.
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.
This undoes a previous stopUpd: of an View.
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.
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.
Sets the cel of the View to newCel.
Sets the loop of the View to newLoop.
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.
Place a view that has been hidden with hide: back on th screen.
Remove the View from the screen, but not from the cast.
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.
If the proper bit is set in signal, remove this View from the cast and do a (super dispose:).
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.
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.
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.
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.