Screen doesn't clear after background(image)
in
Programming Questions
•
10 months ago
Hi, I'm making an android game and need to draw a stars background. I got this to work but now the player sprite leaves trails instead of getting cleared each frame.
Here is the code:
- Playerobject Player;
- PImage[] images = new PImage[10];
- PGraphics Background;
- void setup() {
- size(640,480);
- Player = new Playerobject();
- images[0] = loadImage("spr_player.png");
- images[1] = loadImage("bck_stars.png");
- Createbackground();
- }
- void draw() {
- background(Background);
- imageMode(CENTER);
- Player.display();
- Player.update();
- }
- class Playerobject {
- int xpos = 200;
- int ypos = 200;
- void display() {
- image(images[0],xpos,ypos);
- }
- void update() {
- xpos = round(mouseX);
- ypos = round(mouseY);
- }
- }
- void Createbackground() {
- Background = createGraphics(640,480);
- Background.beginDraw();
- image(images[1],0,0);
- image(images[1],640,480);
- image(images[1],640,0);
- image(images[1],0,480);
- image(images[1],640,960);
- image(images[1],0,960);
- Background.endDraw();
- }
Thanks in advance.
1