⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 spriteanimator.java

📁 CroftSoft Code Library是一个开源的可移植的纯Java游戏库
💻 JAVA
📖 第 1 页 / 共 2 页
字号:

     public void  setSpriteVelocity ( double  spriteVelocity )
     //////////////////////////////////////////////////////////////////////
     {
       for ( int  i = 0; i < sprites.length; i++ )
       {
         sprites [ i ].setVelocity ( spriteVelocity );
       }
     }

     public void  setPaintBackground ( boolean  paintBackground )
     //////////////////////////////////////////////////////////////////////
     {
       this.paintBackground = paintBackground;
     }

     public void  setPaintBricks ( boolean  paintBricks )
     //////////////////////////////////////////////////////////////////////
     {
       this.paintBricks = paintBricks;
     }

     public void  setPaintSprites ( boolean  paintSprites )
     //////////////////////////////////////////////////////////////////////
     {
       this.paintSprites = paintSprites;
     }

     public void  setPaintClouds ( boolean  paintClouds )
     //////////////////////////////////////////////////////////////////////
     {
       this.paintClouds = paintClouds;
     }

     public void  setPaintFogNight ( boolean  paintFogNight )
     //////////////////////////////////////////////////////////////////////
     {
       this.paintFogNight = paintFogNight;
     }

     public void  setOnlySpriteUpdates ( boolean  onlySpriteUpdates )
     //////////////////////////////////////////////////////////////////////
     {
       this.onlySpriteUpdates = onlySpriteUpdates;
     }

     public void  setOnlySpriteRegions ( boolean  onlySpriteRegions )
     //////////////////////////////////////////////////////////////////////
     {
       this.onlySpriteRegions = onlySpriteRegions;
     }

     public void  setUseSystemClock ( boolean  useSystemClock )
     //////////////////////////////////////////////////////////////////////
     {
       if ( useSystemClock )
       {
         clock = SystemClock.INSTANCE;
       }
       else
       {
         clock = new HiResClock ( );
       }
     }

     public void  setLoopGovernor (
       boolean  useFixedDelay,
       double   frequency )
     //////////////////////////////////////////////////////////////////////
     {
       if ( useFixedDelay )
       {
         animatedComponent.setLoopGovernor (
           new FixedDelayLoopGovernor ( frequency ) );
       }
       else
       {
         animatedComponent.setLoopGovernor (           new WindowedLoopGovernor ( frequency ) );       }
     }

     public void  setUseSwingRepaintCollector (
       boolean  useSwingRepaintCollector )
     //////////////////////////////////////////////////////////////////////
     {
       if ( useSwingRepaintCollector )
       {
         animatedComponent.setRepaintCollector (
           new SwingRepaintCollector ( animatedComponent ) );
       }
       else
       {
         animatedComponent.setRepaintCollector (
           DefaultAnimationFactory.INSTANCE.createRepaintCollector ( ) );
       }
     }

     public void  setUseDoubleBuffering ( boolean  useDoubleBuffering )
     //////////////////////////////////////////////////////////////////////
     {
       RepaintManager.currentManager ( animatedComponent )
         .setDoubleBufferingEnabled ( useDoubleBuffering );
     }

     //////////////////////////////////////////////////////////////////////
     // interface Clock method
     //////////////////////////////////////////////////////////////////////

     public long  currentTimeNanos ( )
     //////////////////////////////////////////////////////////////////////
     {
       return updateTimeNanos;
     }

     //////////////////////////////////////////////////////////////////////
     // interface ComponentAnimator methods
     //////////////////////////////////////////////////////////////////////

     public void  update ( JComponent  component )
     //////////////////////////////////////////////////////////////////////
     {
       if ( !initialized )
       {
         return;
       }

       updateTimeNanos = clock.currentTimeNanos ( );

       // Set the bounds here to prevent them from changing during the
       // update.

       component.getBounds ( bounds );

       if ( paintSprites )
       {
         for ( int  i = 0; i < headSprites.length; i++ )
         {
           headSprites [ i ].update ( component );
         }
       }

       if ( !onlySpriteUpdates )
       {
         RepaintCollector  oldRepaintCollector
           = animatedComponent.setRepaintCollector (
           NullRepaintCollector.INSTANCE );

         if ( paintBricks )
         {
           brickTileAnimator.update ( component );
         }

         if ( paintClouds )
         {
           cloudTileAnimator.update ( component );
         }

         if ( paintFogNight )
         {
           fogNightUpdater  .update ( component );
         }

         animatedComponent.setRepaintCollector ( oldRepaintCollector );
       }       cursorAnimator.update ( component );

       for ( int  i = 0; i < rateSprites.length; i++ )
       {
         rateSprites [ i ].update ( component );
       }

       updateRateSampler.update ( component );

       if ( !onlySpriteRegions )
       {
         component.repaint ( );
       }
     }

     public void  paint (
       JComponent  component,
       Graphics2D  graphics )
     //////////////////////////////////////////////////////////////////////
     {
       if ( !initialized )
       {         try         {
           initialize ( );         }         catch ( IOException  ex )         {           ex.printStackTrace ( );         }
       }

       if ( paintBackground )
       {
         brickColorPainter.paint ( component, graphics );
       }

       if ( paintBricks )
       {
         brickTileAnimator.paint ( component, graphics );
       }

       if ( paintSprites )
       {
         for ( int  i = 0; i < headSprites.length; i++ )
         {
           headSprites [ i ].paint ( component, graphics );
         }
       }

       cursorAnimator.paint ( component, graphics );

       if ( paintClouds )
       {
         cloudTileAnimator.paint ( component, graphics );
       }

       if ( paintFogNight )
       {
         fogNightColorPainter.paint ( component, graphics );
       }

       paintRateSampler.paint ( component, graphics );

       for ( int  i = 0; i < rateSprites.length; i++ )
       {
         rateSprites [ i ].paint ( component, graphics );
       }
     }

     //////////////////////////////////////////////////////////////////////
     // private methods
     //////////////////////////////////////////////////////////////////////

     private Icon  validateIcon ( String  imageFilename )       throws IOException
     //////////////////////////////////////////////////////////////////////
     {
       Icon  icon = ( Icon ) iconMap.get ( imageFilename );

       if ( icon == null )
       {
         Image  image           = loadAutomaticImage ( imageFilename, Transparency.BITMASK );
         if ( image == null )
         {
           return null;
         }

         icon = new ImageIcon ( image );

         iconMap.put ( imageFilename, icon );
       }

       return icon;
     }     private BufferedImage  loadAutomaticImage (       String  imageFilename,       int     transparency )       throws IOException     //////////////////////////////////////////////////////////////////////     {       return ImageLib.loadAutomaticImage (         imageFilename,         transparency,         animatedComponent,         getClass ( ).getClassLoader ( ),         null );     }     //////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////
     }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -