我在使用 Java 处理 Processing 2.0 软件时遇到了一个问题。每次添加动画时,我也会添加背景以擦除此动画的前一帧。不幸的是,这个过程也删除了我的其余图形。有没有办法在不添加新背景的情况下为 PShape 设置动画?或者有没有更好的方法来动画形状?我还想提一下,我使用的是 ActionScript 语言,我对动画的理解是基于 MovieClip。
谢谢。
编辑:下面添加的代码:
应用程序入口点
LineManager lineManager;
Character character;
void setup() {
size( 300, 600 );
background( 50 );
rectMode( CENTER );
frameRate( 24 );
lineManager = new LineManager();
character = new Character();
}
void draw() {
character.onTick();
}
字符类
public class Character {
float MIN_VALUE = 80;
float value = MIN_VALUE;
float radius = 50.0;
int X, Y;
int nX, nY;
int delay = 16;
PShape player;
public Character() {
X = width / 2;
Y = height / 2;
nX = X;
nY = Y;
player = loadShape("player.svg");
}
public void onTick() {
value = value + sin( frameCount/4 );
X += (nX-X)/delay;
Y += (nY-Y)/delay;
/*
** My issue is the line below, as when adding it to render the animation
** I end up hiding the rest of my graphics
*/
background(0);
ellipse( X, Y, value, value );
shape( player, -10, 140, 320, 320 );
fill( 222, 222, 222, 222 );
}
}