none
Shapes info RRS feed

  • Question

  • Is there a way to animate a ball and zooming it to become bigger or smaller as it moves along?
    Monday, November 29, 2010 7:27 PM

Answers

  • Yes, all you have to do is use Shapes.Zoom at the same time you use Shapes.Move.  I don't think there is a way to do it using the Shapes.Animate method, which is generally most useful for simple aninmated title screens for example rather than dynamics simulations of a ball.  You will need to calculate the zoom factor and maybe store its value in an array, just as you do its position or velocity; simple example:

    gw = GraphicsWindow.Width
    gh = GraphicsWindow.Height

    x = gw/2
    y = gh/2
    u = 1
    v = 1
    radius = 25
    ball = Shapes.AddEllipse(2*radius,2*radius)

    While ("True")
      x = x+u
      y = y+v
      zoom = 1+2*y/gh
      If (x < zoom*radius) Then
        x = 2*zoom*radius-x
        u = -u
      ElseIf (x > gw-zoom*radius) Then
        x = 2*(gw-zoom*radius) - x
        u = -u
      EndIf
      If (y < zoom*radius) Then
        y = 2*zoom*radius-y
        v = -v
      ElseIf (y > gh-zoom*radius) Then
        y = 2*(gh-zoom*radius) - y
        v = -v
      EndIf
      Shapes.Move(ball,x-radius,y-radius)
      Shapes.Zoom(ball,zoom,zoom)
      Program.Delay(5)
    EndWhile

    • Marked as answer by Rushworks Wednesday, December 1, 2010 1:44 AM
    Monday, November 29, 2010 7:49 PM
    Moderator

All replies

  • Yes, all you have to do is use Shapes.Zoom at the same time you use Shapes.Move.  I don't think there is a way to do it using the Shapes.Animate method, which is generally most useful for simple aninmated title screens for example rather than dynamics simulations of a ball.  You will need to calculate the zoom factor and maybe store its value in an array, just as you do its position or velocity; simple example:

    gw = GraphicsWindow.Width
    gh = GraphicsWindow.Height

    x = gw/2
    y = gh/2
    u = 1
    v = 1
    radius = 25
    ball = Shapes.AddEllipse(2*radius,2*radius)

    While ("True")
      x = x+u
      y = y+v
      zoom = 1+2*y/gh
      If (x < zoom*radius) Then
        x = 2*zoom*radius-x
        u = -u
      ElseIf (x > gw-zoom*radius) Then
        x = 2*(gw-zoom*radius) - x
        u = -u
      EndIf
      If (y < zoom*radius) Then
        y = 2*zoom*radius-y
        v = -v
      ElseIf (y > gh-zoom*radius) Then
        y = 2*(gh-zoom*radius) - y
        v = -v
      EndIf
      Shapes.Move(ball,x-radius,y-radius)
      Shapes.Zoom(ball,zoom,zoom)
      Program.Delay(5)
    EndWhile

    • Marked as answer by Rushworks Wednesday, December 1, 2010 1:44 AM
    Monday, November 29, 2010 7:49 PM
    Moderator
  • Thanks
    Tuesday, November 30, 2010 3:52 PM