The default puppet state is false. This means that initially, all sprites act under the control of the score. When you issue a
puppetSprite channelNum, truecommand, the specified sprite's behaviour is detached from the score and you can manipulate it via lingo. Conversely, a
puppetSprite channelNum, falsecommand releases the sprite from script control and returns it to the score.
So, whenever you want to control sprites via lingo, you need to make them puppets, and this tends to be necessary for anything but the most rudimentary interactivity.
First of all, score control includes all those places where you jump to some other frame and want the stage to look the way you set it up in that frame. If you do this with some of your sprites set as puppets, they generally won't change in the way you want, but will stay as your scripts have left them. In general, therefore, you should unpuppet things before any major "go to" commands.
Secondly, the score only asserts its control if there's something for it to do, such as a transition or a loop. If there's a sprite onstage which doesn't move or change in the score, your lingo scripts may be able to move it around and manipulate it for a while even though it isn't a puppet. In general this isn't a good idea, since as soon as the score finds something to do with the sprite all your changes will be lost.
Thirdly, puppetness is a property of a channel, rather than a sprite, so lingo will quite happily let you puppet a channel that doesn't have anything in it. This is almost invariably a bad thing to do and leads to unpredictable and frequently ugly behaviour. Always make sure there's something in a channel before puppeting it.
As mentioned above, another thing which can make puppets behave strangely is if they were declared puppets with nothing in the channel.
The puppetPalette command can be used to change the current palette and to create transitions between the current palette and the one being changed to:
puppetPalette "myPalette", 20 -- 20 represents the rate if transitionLike puppetSprite channels, puppetPalettes persist until reset with a
puppetPalette 0command, and the contents of the palette channel will be ignored until such a command is issued.
Other palette channel effects, like Fade To Black, cannot be directly performed from Lingo.
Transitions can be generated with the puppetTransition command:
puppetTransition 37, 0, 8, false-- see the Lingo Dictionary for a full list of the parameters for this!
The transition will occur on the next frame entry. This includes re-entering the current frame. If you are paused on the frame, you could force the transition to occur by adding
go the frameafter your puppetTransition command. Puppet transitions do not persist, but take place only once.
The sound channel can be puppeted using the puppetSound command, for which the official syntax is:
puppetSound mySoundCastIn this case, only sound channel 1 is affected. PuppetSound both specifies a sound to be played and makes the first sound channel a puppet. The channel remains under lingo control until a
puppetSound 0command is issued. Until then, score instructions in sound channel 1 will be ignored and sounds will only be played by issuing further puppetSound commands.
However, an undocumented feature is the use of puppetSound with multiple sound channels:
puppetSound channelNumber, cast mySoundCastWith Macromedia's MacroMix DLL providing the mixing ability of Apple's Sound Manager 3 under Windows, this seems to work seamlessly cross-platform as of version 4.0.4, but as usual the caveats of section 1.8 need be borne in mind.
The volume of individual sound channels can be varied independently by using the volume of sound property:
set the volume of sound channelNumber = 255Sound volume is officially restricted to the range 0-255, but on the Mac at least it may be overdriven to higher levels if desired.
Finally, the tempo can be changed using the puppetTempo command:
puppetTempo 30This will adjust the frame rate of the Director movie. The new tempo stays in effect until altered either by another puppetTempo command or by a change in the tempo channel.
Other tempo channel effects (waiting for a specific time or for a particular event) must be scripted explicitly. This is commonly done by looping on the frame until the required event takes place, eg to wait for a mouseClick:
-- you probably shouldn't do this this way with a slow frameRate...
on exitFrame
if not the mouseDown then go the frame
end exitFrame
-- puppetizing a sprite with nothing in the score on insertNonPuppet stageSprite, cstNum, where -- first puppet the channel puppetsprite stagesprite,true -- set its properties set the castNum of sprite stageSprite = cstNum set the type of sprite stageSprite = 16 set the ink of sprite stageSprite = 0 set the foreColor of sprite stageSprite = 255 set the backColor of sprite stageSprite = 0 -- in this case we'll just place our new cast -- and keep it at it's natural size, but in theory -- we may want to adjust its rect set the loc of sprite stageSprite = where set the stretch of sprite stageSprite = false -- update it updatestage end insertNonPuppet[Thanks to Paul Farry <p.farry@cqu.edu.au> for demonstrating this technique.]
Director Web:
Director FAQ [11]: Puppets
HTML by Zac Belado, zac@wimsey.com
The Internet Connection at MCLI is
Alan Levine --}
Comments to
levine@maricopa.edu
URL: http://www.mcli.dist.maricopa.edu/director/faq/faq11.html