문제

I'm new to PlayN, now I'm trying to draw an image. Seems that examples on the official page (https://developers.google.com/playn/devguide/rendering) were not updated for a long time, they simply don't work with the latest version of PlayN.

I have global CanvasImage circle and SurfaceLayer surf. In my init() I have this code:

Graphics g = PlayN.graphics();
surf = g.createSurfaceLayer(g.width(), g.height());
g.rootLayer().add(surf);

And this in paint():

surf.surface().clear();
surf.surface().drawImage(circle, 0, 0);

The compiler warns that createSurfaceLayer() method is deprecated and offers to use createSurface() and createImageLayer() methods instead. How do I use it correctly?

도움이 되었습니까?

해결책

I just changed SurfaceLayer surf to ImageLayer imglay, removed all the code from paint() and replaced code in init() to this:

imglay = g.createImageLayer();
imglay.setImage(circle);
g.rootLayer().add(imglay);

It works, but is it how it should be done?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top