Page 1 of 1

how to move text continuously inside a window

Posted: Fri Sep 12, 2008 7:46 pm
by yabune
hi,

I would like to create a moving marquee inside a window (like we have in html).

Any tips on this?

Thanks!

Posted: Mon Sep 15, 2008 5:15 pm
by yabune
ok, I have a solution:

Code: Select all

x = 0
y = 0

If OpenWindow(0, 100, 200, 300, 260, "Marquee")

  CreateImage(0, 300, 20)
  CreateGadgetList(WindowID(0))
  ImageGadget(0, 0, 100, 0, 0, ImageID(0))

  last = ElapsedMilliseconds()
  

  Repeat
    EventID = WindowEvent()

    If EventID = #PB_Event_CloseWindow
      Quit = 1
    Else
      Delay(1)
    EndIf
    
    current = ElapsedMilliseconds()
    If(current - last >= 20)
      x = x + 1
      CreateImage(0, 300, 20)
      StartDrawing(ImageOutput(0))
      
      DrawingMode(1)
      
      BackColor(RGB(0,155,155))
      FrontColor(RGB(255,255,255))
      DrawText(x,y,"Hello, this is a test")
      
      StopDrawing()
      
      SetGadgetState(0, ImageID(0))
      
      last = ElapsedMilliseconds()
    EndIf

  Until Quit = 1



EndIf

End

But I can't make it move smoothly...

Anyone knows how to make the animation more smooth?

Thanks

Posted: Wed Sep 17, 2008 2:28 am
by citystate
the search function is your friend (of course it helps that I remember coding something along these lines :P)

http://www.purebasic.fr/english/viewtopic.php?t=22826