Meaningless Drivel is fun!
The moose likes Java Micro Edition and the fly likes How to set traverse string using canvas Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "How to set traverse string using canvas" Watch "How to set traverse string using canvas" New topic

How to set traverse string using canvas

nagarjuan pula

Joined: Sep 20, 2010
Posts: 9
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17410

The text crawl effect is done by erasing the old text and writing it back into the canvas again only with a shifted "X" co-ordinate. You can do erasing in several different ways. One is by just resetting the rectangle that bounds the text to the canvas background color. Another is to rewrite the text in its original position, but using the canvas background color as the text color.

Then again, if the UI supports clipping (and I don't remember for the case of JME), you could simply set a clip rectangle to only repaint the area that holds the text and update the X co-ordinate in the paint method. Which is the preferred way to do things in systems that do painting in separate threads. For one thing, the clip/paint mechanism usually makes most effective use of the available graphics hardware and isn't impacted by other UI events.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: How to set traverse string using canvas
It's not a secret anymore!