在使用Java处理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 );
}
}发布于 2013-06-20 02:43:46
Processing方言不支持独立的图形层,但有很多第三方库可以让你这样做,比如this one (last update: 2011)。
查看Processing's site上动画部分下的主库的更新列表。
https://stackoverflow.com/questions/17197818
复制相似问题