Turning Image bluring OFF
in
Programming Questions
•
2 years ago
EDIT: Changing to renderer in the size() function from P2D to JAVA2D fixed it. If there is a way to turn it off in the P2D renderer let me know. >< I didn't occur to me until after I posted this...
I'm making a game engine using Processing in Netbeans.
I have a sprite object and when I try to flip it across the X axis the frames end up blurred. Is there any way to turn that off?
I have the XScale set to -1 in the main class.
Here's my sprite code.
I'm making a game engine using Processing in Netbeans.
I have a sprite object and when I try to flip it across the X axis the frames end up blurred. Is there any way to turn that off?
I have the XScale set to -1 in the main class.
Here's my sprite code.
- package c13engine;
import processing.core.*;
/**
*
* @author ChrisXIII
*/
public class C13Sprite {
public static final int LOOP = 1;
public static final int ONE_SHOT = 2;
public static final int PING_PONG = 3;
public static final int TOP_LEFT = 1;
public static final int TOP_CENTER = 2;
public static final int TOP_RIGHT = 3;
public static final int LEFT = 4;
public static final int CENTER = 5;
public static final int RIGHT = 6;
public static final int BOTTOM_LEFT = 7;
public static final int BOTTOM_CENTER = 8;
public static final int BOTTOM_RIGHT = 9;
private PApplet p;
public PImage[] frames;
private int animType;
public int drawType = TOP_LEFT;
public float imageIndex = 0;
public float imageSpeed = 1;
public float XScale = 1;
public float YScale = 1;
public float rotation = 0;
private boolean PP_forward = true;
public C13Sprite(PApplet papp, PImage[] imgs, int type) {
p = papp;
frames = imgs;
animType = type;
}
public void updateFrame() {
switch(animType) {
case LOOP:
imageIndex += ((int)Math.floor(imageIndex+imageSpeed)
>= frames.length) ? -imageIndex : imageSpeed ;
break;
case ONE_SHOT: imageIndex += ((int)Math.floor(imageIndex+imageSpeed)
== frames.length) ? 0 : 1;
break;
case PING_PONG:
if (imageIndex == 0 && !PP_forward) {
PP_forward = true;
}
if (imageIndex+1 == frames.length && PP_forward) {
PP_forward = false;
}
imageIndex += PP_forward ? 1:-1; break;
}
}
public void draw(int x,int y) {
p.pushMatrix();//-------------------------------------------------------
p.translate(x, y);
p.scale(XScale,YScale);
p.rotate(rotation);
PImage img = frames[(int)Math.floor(imageIndex)];
switch(drawType) {
case TOP_LEFT: p.image(img,0,0); break;
case TOP_CENTER: p.image(img,(int)-img.width/2,0); break;
case TOP_RIGHT: p.image(img,(int)-img.width,0); break;
case LEFT: p.image(img, 0, (int)-img.height/2); break;
case CENTER: p.image(img, (int)-img.width/2, (int)-img.height/2); break;
case RIGHT: p.image(img, -img.width, (int)-img.height/2); break;
case BOTTOM_LEFT: p.image(img, 0, -img.height); break;
case BOTTOM_CENTER: p.image(img, (int)-img.width/2, -img.height); break;
case BOTTOM_RIGHT: p.image(img, -img.width, -img.height); break;
default: p.image(img,0,0); break;
}
p.popMatrix();//--------------------------------------------------------
}
}
1