且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何让我所有的子弹删除相交的对象

更新时间:2023-11-21 18:58:58

我最终做到了这一点,将我的项目符号添加到另一个数组列表中,然后在测试交集时从数组列表中获取项目符号.

I Finally did this by adding my bullet to another arraylist, then getting bullets from the arraylist when testing for intersection.

 ArrayList<Rectangle2D.Float> bulletStore=new ArrayList<>();
        Rectangle2D.Float bullet;//=new Rectangle2D.Float(bx_pos,by_pos+10,3,10);

      for(int j=0;j<by_poss.size();j++){
        by_poss.set(j, by_poss.get(j)+y_speed); //move the bullet
         bullet=new Rectangle2D.Float(bx_poss_motion.get(j),by_poss.get(j),3,10);
      //Rectangle2D.Float bulletOu=new Rectangle2D.Float(bx_pos,by_pos+10,3,10);

            g2.fill(bullet);
       bulletStore.add(bullet);
            //g2.draw(bullet);
   }



 if(b.intersects(bulletStore.get(j))){