6.
Repain%ng
• You
never
call
the
paint()
method.
• Instead
of
you
use
repaint():
– By
using
this
method,
you
ask
the
framework
to
repaint
the
canvas
– Framework
decides
when
is
the
best
%me
to
repaint
the
canvas
• There
is
a
also:
– repaint(int x, int y, int width, int
height)

11.
Game
API
• It
is
easy
to
handle
anima%on
and
graphics
with
the
Game
API
• All
the
classes
can
be
found
from
javax.microedition.lcdui.game.*;

12.
GameCanvas
• Using
the
tradi%onal
Canvas-­‐class
– You
inherit
the
Canvas
and
override
paint-­‐method.
– repaint()
– Event
handling
is
done
by
using
methods
like
keypressed,
keyreleased
• Using
the
GameCanvas-­‐class
– You
inherit
the
GameCanvas-­‐class
– There
is
no
need
for
paint-­‐method,
you
can
draw
anywhere!
– flushGraphics()
– Two
ways
of
doing
event
handling!

14.
Handling
Events
• Constructor
of
GameCanvas
– protected GameCanvas(boolean
suppressKeyEvents)
• You
have
to
call
this
constructor
in
you
own
GameCanvas
class..
– =>
You
have
to
give
a
boolean
value..
– true:
use
only
GameCanvases
own
event
handling
– false:
in
addi4on
to
GameCanvases
own
event
handling
use
Canvases
event
handling

40.
TiledLayer
• A
TiledLayer
is
a
visual
element
composed
of
a
grid
of
cells
that
can
be
ﬁlled
with
a
set
of
%le
images.
• Rows
and
Columns
– TiledLayer(int columns, int rows, Image
i, int tileWidth, int tileHeight);