当前位置: 首页>>代码示例>>Java>>正文


Java PShape.removeChild方法代码示例

本文整理汇总了Java中processing.core.PShape.removeChild方法的典型用法代码示例。如果您正苦于以下问题:Java PShape.removeChild方法的具体用法?Java PShape.removeChild怎么用?Java PShape.removeChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在processing.core.PShape的用法示例。


在下文中一共展示了PShape.removeChild方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateParticleShapeBuffer

import processing.core.PShape; //导入方法依赖的package包/类
@Deprecated
static final public int updateParticleShapeBuffer(World world, PShape group_particles){
  int particle_num_old = world.getParticleCount();
  int particle_num_new = 0;
  
  if(particle_num_old == 0){
    return 0;
  }
  
  if(group_particles.getChildCount() == 0){
    return 0;
  }
  
  // The following is way faster, then removing shapes in place.
  // ... even when iterating backwards, a lot of repeated/unnecessary copying 
  // will be needed.

  PShape group = group_particles;
  PShape[] shapes = group.getChildren();
  int[] particle_flag = world.getParticleFlagsBuffer();
  

  // re-map particles, so that zombies are left out
  for(int i = 0; i < particle_num_old; i++){
    if((particle_flag[i] & ParticleType.b2_zombieParticle) == 0){
      shapes[particle_num_new++] = shapes[i];
    }
  }
  
  // remove number of zombies by triming the buffer to the new size
  // unfortunately PShape offers no better way to do this
  for(int i = particle_num_old - 1; i >= particle_num_new; i--){
    group.removeChild(i);
  }
  
  
  int removed = particle_num_old - particle_num_new;
  
  return removed;
}
 
开发者ID:diwi,项目名称:LiquidFunProcessing,代码行数:41,代码来源:DwUtils.java

示例2: removeChilds

import processing.core.PShape; //导入方法依赖的package包/类
private void removeChilds(PShape shp){
  if(shp == null){
    return;
  }
  int num_childs = shp.getChildCount();
  for(int i = num_childs-1; i >= 0; i--){
    removeChilds(shp.getChild(i));
    shp.removeChild(i);
  }
}
 
开发者ID:diwi,项目名称:PixelFlow,代码行数:11,代码来源:DwSoftBody.java


注:本文中的processing.core.PShape.removeChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。