We defined the type of the surface
variable as PSurfaceFX
.
PSurfaceFX
is a sub-type of PSurface
.
super.initSurface()
does indeed return a PSurfaceFX
object but the compiler only knows that it is an object of type PSurface
.
So, we need to cast the PSurface
object that it returns to a PSurfaceFX
type, so the type corresponds with the surface
variable:
surface = (PSurfaceFX) super.initSurface();