While writing a letter in MS Word, I accidentally clicked on the help button and this animated little thing on a a bike jumped up and presented me with an input box. I’ve seen it a few times before, but this time I wondered if I could write a program that could animate characters in Delphi.
Delphi and Microsoft Agent - Other features of the Agent (Page 4 of 4 )
You can move the agent around the screen by using the Moveto() method. The method takes three parameters:
Moveto(x,y,0)
The agents can also interact with each other. This can be achieved by using the request and wait methods. The code could look something like this:
//create the vars var Request1, Request2 : IAgentCtlRequest; //load the agents Agent1.characters.load('Merlin','merlin.acs'); Merlin:=Agent1.Characters.Character('Merlin'); Agent1.characters.load('Peedy','peedy.acs'); Peedy := Agent1.Characters.Character('Peedy'); //make them visible Peedy.Show(False); merlin.Show(False); //start the interaction Request1 := Peedy.Speak('Hello there',''); merlin.Wait(Request1); Request2 := merlin.Speak('Who''s there?',''); Peedy.Wait(Request2); Request1 := Peedy.Speak('Its me Peedy.',''); merlin.Wait(Request1); Request2 := merlin.Speak('Peedy who?',''); Peedy.Wait(Request2); Request1 := Peedy.Speak('Just Peedy!',''); merlin.Wait(Request1); Peedy.Play('Pleased'); merlin.Play('Pleased');
To interact with the user, as opposed to another agent, you just need to use input boxes and make the agent read your responses.
Conclusion
Agents will make your applications interactive and fun to use. And with some of the core components that you installed, you can build your own characters to use in your applications.
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.