Programming Help:MoveTo Method
Appearance
| MoveTo Method | |
|---|---|
| The MoveTo Method moves the specified character to the specified location. |
|
| Introduced in version: | Microsoft Agent 1.5 |
| Removed in version: | Still in use |
| Allowed values: | x, y (pixel coordinates, required) Speed (movement speed optional) |
| Default value: | 1000 (speed) |
Parts
| Part | Description |
|---|---|
| x,y | Required. An integer value that indicates the left edge (x) and top edge (y) of the animation frame. Express these coordinates in pixels. |
| Speed | Optional. A long integer in milliseconds how quickly the character's frame moves. The default value is 1000 with 0 allowing the character to move without activating the moving animation (if any). |
Examples
Inline example (VB.NET)
robby.MoveTo(125, 600, 0)
Advanced example (VB.NET)
' NOTE: This utilizes two panel elements to determine where to place the character based on size (smaller than 128px or larger)
Private Function GetSpawnPanelForCurrentCharacter() As Panel
' small panel
Dim target As Panel = AgentSpawnPanel
If robby Is Nothing Then
Return target
End If
Try
' Agent has .Width and .Height built in
Dim w As Integer = robby.Width
Dim h As Integer = robby.Height
' SpawnPanel2 for 128x128 or larger characters
If w >= 128 OrElse h >= 128 Then
target = SpawnPanel2
End If
Catch
' fallback
End Try
Return target
End Function
Dim targetPanel As Panel = GetSpawnPanelForCurrentCharacter()
If targetPanel Is Nothing Then Exit Sub
Dim panelScreenPos As Point = targetPanel.PointToScreen(Point.Empty)
Dim centerX As Integer = panelScreenPos.X + targetPanel.Width \ 2
Dim centerY As Integer = panelScreenPos.Y + targetPanel.Height \ 2
robby.MoveTo(centerX, centerY, 0)
Remarks
The Microsoft Agent Server (AgentSvr.exe) automatically plays the appropriate animation assigned to the moving states selected in the Microsoft Agent Character Editor: MoveLeft, MoveRight, MoveUp, MoveDown.