locked
Clearing only certain things in a window? RRS feed

  • Question

  • I'm trying to write a program that allows the user to drag a circle around with their mouse, and do various things with it, depending where it goes. I am trying to include a timer, but I can't clear the previous number to put the new second count on top without erasing the entire screen. Please help me! Here is my current code:

    GraphicsWindow.brushColor= "LightPink"
    ball= Shapes.AddEllipse(25,25)
    GraphicsWindow.MouseMove= OnMouseMove
    x= GraphicsWindow.MouseX
    y= GraphicsWindow.MouseY
    Timer.Interval= 1000
    Timer = 1
    Timer.tick= OnTimerTick
    Sub OnTimerTick
      GraphicsWindow.DrawText(100,100,timer)
      timer= timer+1
    EndSub
    Sub OnMouseMove
      ballX= GraphicsWindow.MouseX -10
      ballY= GraphicsWindow.MouseY -10
      Shapes.Move(ball, ballX-8,ballY-8)
    EndSub

    Wednesday, November 14, 2012 7:21 PM

Answers

  • Or if you insist on GW use this sub instead of yours:

    Sub OnTimerTick
      GraphicsWindow.BrushColor = GraphicsWindow.BackgroundColor
      GraphicsWindow.FillRectangle(100,100,100,100)
      GraphicsWindow.brushColor= "LightPink"
      GraphicsWindow.DrawText(100,100,timer)
      timer= timer+1
    EndSub


    One thing that is impossible is impossible no matter if it is proven so first.


    Wednesday, November 14, 2012 8:30 PM
    Answerer

All replies

  • Your problem is that you are using graphicswindow text. try shapes text. like this:

    GraphicsWindow.Show()
    Timer.Interval = 1000
    Timer.Tick = Time
    Timetext = Shapes.AddText(1)
    Shapes.Move(Timetext,20,20)
    Sub Time
      timenum = timenum + 1
      Shapes.SetText(Timetext,timenum)
      EndSub


    One thing that is impossible is impossible no matter if it is proven so first.

    Wednesday, November 14, 2012 8:27 PM
    Answerer
  • Or if you insist on GW use this sub instead of yours:

    Sub OnTimerTick
      GraphicsWindow.BrushColor = GraphicsWindow.BackgroundColor
      GraphicsWindow.FillRectangle(100,100,100,100)
      GraphicsWindow.brushColor= "LightPink"
      GraphicsWindow.DrawText(100,100,timer)
      timer= timer+1
    EndSub


    One thing that is impossible is impossible no matter if it is proven so first.


    Wednesday, November 14, 2012 8:30 PM
    Answerer
  • That's perfect! Thank you so much!
    Thursday, November 15, 2012 6:32 PM