【问题标题】:Animation issue using Processing 2.0 Java使用 Processing 2.0 Java 的动画问题
【发布时间】:2013-06-19 17:44:42
【问题描述】:

我在使用 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 );
  }
}

【问题讨论】:

  • 附上代码

标签: java animation processing


【解决方案1】:

Processing 方言不支持独立的图形层,但是有很多第三方库可以让你做到这一点,比如this one (last update: 2011)

查看Processing's site动画部分下的主要库的更新列表。

【讨论】:

  • 谢谢。这正是我所需要的。
猜你喜欢
  • 2016-11-29
  • 2014-04-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-11-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多