亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? sprite.java

?? 在手機環境里運行的J2ME坦克類射擊游戲源代碼
?? JAVA
字號:
/*
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 *  Copyright(c) 2003-2004 Jordi Martin Perez
 *  $Id: Sprite.java,v 1.4 2004/07/01 22:17:51 piratis Exp $
*/
package org.piratis.j2me.core.game;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

/**
 * Provide some basic sprite functionality: getting and setting of coordinates 
 * and dimensions, as well as simple collision detection.
 * 
 * @author		Jordi Mart韓
 * @copyright	Copyright (c) 2004
 * @created 	24-jun-2004
 * @version		$Id: Sprite.java,v 1.4 2004/07/01 22:17:51 piratis Exp $
 */
public class Sprite
	extends Layer
{
    /**
     * for inner image management!
     */
    private Image image;
    
    /**
     * Animated sprite / frame related vars
     */
    private int frame;
    private int nFrames;
    private int nFramesRow;
    private int nFramesCol;
    private int frameX;
    private int frameY;
    
    /**
     * frame sequence to follow
     */
    private int[] frameSequence;
    
    /**
     * Current frame will return this if there is no animated sprite
     */
    public static int NO_FRAME = -1;
    
    /**
     * New 'static' Sprite with the given Image. 
     * @param image the Image to use
     */
    public Sprite(Image img)
    {
        this.image = img;
        this.bbox.width = img.getWidth();
        this.bbox.height = img.getHeight();
        // no dynamic!
        this.frame = Sprite.NO_FRAME;
        this.nFrames = 1;
    }
    
    /**
     * New 'dynamic' (animtaed) Sprite with the given frames contained in the Image.
     * Each frame has the same size (frameWidth x frameHeight). The Image provided
     * might conform whatever layout, but its overall width and height must be a an
     * integer multiple of the frame width and height.<br>
     * <br>
     * Aside from that, the Sprite will behave as a static Sprite regarding its
     * width and height (by calling {@link Layer#getBbox()}).
     * @param img Image containing the frames
     * @param frameWidth the width of each frame
     * @param frameHeight the height of each frame
     */
    public Sprite(Image img, int frameWidth, int frameHeight)
    {
        this.image = img;
        this.bbox.width = frameWidth;
        this.bbox.height = frameHeight;
        // precalc nFrames X row and X col
        this.nFramesRow = img.getWidth() / frameWidth;
        this.nFramesCol = img.getHeight() / frameHeight;
        this.nFrames = this.nFramesRow*this.nFramesCol;
        this.frame = this.frameX = this.frameY = 0;
        // default frame sequence
        this.setDefaultFrameSequence();
    }

    /**
     * Paints the Sprite into the Graphics object provided.
     * @see Layer#paint(javax.microedition.lcdui.Graphics)
     */
    public final void paint(Graphics g)
    {
        if (!isVisible()) return;

        if (this.nFrames > 1)
        {
            // clip to paint only the current frame
            int clipX, clipY, clipW, clipH;
            clipX = g.getClipX(); clipY = g.getClipY();
            clipW = g.getClipWidth(); clipH = g.getClipHeight();
            g.clipRect(this.bbox.x, this.bbox.y, 
                    this.bbox.width, this.bbox.height);
            // move the image origin
            g.translate(-this.frameX, -this.frameY);
            // draw image
            g.drawImage(this.image, this.bbox.x, this.bbox.y,
                    Layer.TOP_LEFT);
            // undo the image origin translation
            g.translate(this.frameX, this.frameY);
            // restore clipping values
            g.setClip(clipX, clipY, clipW, clipH);
        }
        else
        {
            // simple image drawing
	        g.drawImage(this.image, this.bbox.x, this.bbox.y, 
	                Graphics.TOP|Graphics.LEFT);
        }
    }

    /**
     * Gets the current frame index
     * @return the index in the frame sequence
     */
    public int getFrame()
    {
        return this.frame;
    }

    /**
     * Selectes the current frame in the current sequence.<br>
     * <br>
     * The index refers to the position in the frame sequence, not to the
     * frame index (within the Image).
     * 
     * @param newFrame the index of the desired frame to be displayed on the next
     *	paint call of the current sequence
     * @throws IndexOutOfBoundsException if the index is out of the bound of the
     * 	current frame sequence
     */
    public void setFrame(int newFrame)
    	throws IndexOutOfBoundsException
    {
        if (this.nFrames > 1 && (newFrame < 0 || newFrame > this.frameSequence.length))
            throw new IndexOutOfBoundsException("Sprite#setFrame(" + newFrame + "), given index is out of bounds!");
        // set frame
        this.frame = newFrame;
        int theFrame = this.frameSequence[this.frame];
        // recalc X & Y
        if (this.nFrames > 1)
        {
            this.frameX = (theFrame % this.nFramesRow) * this.bbox.width;  // newFrame % framesRow = col
            this.frameY = (theFrame / this.nFramesRow) * this.bbox.height; // newFrame / framesRow = row
        }
    }
    
    /**
     * Moves forward to the next frame in sequence<br> 
     * <br>
     * Frame sequences are circular: when reached the end of the sequence, it
     * will continue at the beginning.
     * @see #prevFrame()
     */
    public void nextFrame()
    {
        this.setFrame( (this.frame+1) % this.frameSequence.length );
    }

    /**
     * Moves backward to the previous frame in sequence<br> 
     * <br>
     * Frame sequences are circular: when reached the beginnig of the sequence, it
     * will continue at the last frame.
     * @see #nextFrame()
     */
    public void prevFrame()
    {
        this.setFrame( (this.frame-1)<0?this.frameSequence.length-1:this.frame-1 );
    }
    
    /**
     * Establish the frame sequence of the Sprite.
     * @param sequence
     */
    public void setFrameSequence(int[] sequence)
    {
        // initial frame
        this.frame = 0;
        if (sequence != null)
        {
            // copy array
            this.frameSequence = new int[sequence.length];
            System.arraycopy(sequence, 0, this.frameSequence, 0, sequence.length);
        }
        else
            this.setDefaultFrameSequence();
    }
    
    /**
     * Sets the default frame sequence -> 0..nFrames-1  
     */
    private void setDefaultFrameSequence()
    {
        this.frameSequence = null;
        if (this.nFrames > 1)
        {
            this.frameSequence = new int[this.nFrames];
            // backward looping is quicker!
            for (int i=this.nFrames-1; i >= 0; i--)
                this.frameSequence[i] = i;
        }
    }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品亚洲一区二区三区在线| 国产亚洲精品中文字幕| 成人精品免费看| 精品亚洲国产成人av制服丝袜 | 麻豆成人久久精品二区三区红| 亚洲欧美日韩综合aⅴ视频| 久久久99精品免费观看不卡| 久久影院午夜论| 欧美韩日一区二区三区| 国产精品污www在线观看| 国产精品久久久久影院| 亚洲国产精品av| 国产精品黄色在线观看| 欧美经典一区二区| 成人欧美一区二区三区| 日本韩国一区二区| 视频在线观看一区二区三区| 午夜视频在线观看一区二区 | 国产传媒久久文化传媒| 国产精品一区二区在线播放 | 高清在线观看日韩| 97久久精品人人澡人人爽| av电影在线观看完整版一区二区| 91麻豆国产福利精品| 欧美日韩一区二区电影| 欧美一区二区三区在线| 久久久久久免费| 亚洲美女视频一区| 青青草伊人久久| 国产69精品久久久久777| 91久久人澡人人添人人爽欧美| 欧美三级乱人伦电影| 九九在线精品视频| 日韩电影在线看| 国产成人免费视频网站高清观看视频| 国产a区久久久| 欧美在线你懂得| 2021久久国产精品不只是精品| 国产精品女人毛片| 日韩国产欧美一区二区三区| 国产高清在线观看免费不卡| 欧美色偷偷大香| 久久精品一区四区| 亚洲成av人片| 成人午夜视频福利| 欧美一级高清大全免费观看| 国产精品九色蝌蚪自拍| 韩国av一区二区三区四区| 91浏览器打开| 久久久99免费| 毛片av中文字幕一区二区| 99久久精品久久久久久清纯| 精品黑人一区二区三区久久| 一区二区在线观看视频在线观看| 国产乱码精品一区二区三区忘忧草 | 日本道免费精品一区二区三区| 日韩一区二区免费在线电影| 亚洲欧美日韩中文播放| 国产成人免费高清| 欧美一区二区三区四区五区| 亚洲一区二区三区精品在线| 成人精品一区二区三区中文字幕| 日韩一区和二区| 午夜精品一区在线观看| 91丝袜呻吟高潮美腿白嫩在线观看| 久久蜜臀中文字幕| 美女视频一区二区| 91精品国产入口| 亚洲高清一区二区三区| 在线观看日韩国产| 亚洲视频 欧洲视频| 成人aaaa免费全部观看| 久久久国产精品不卡| 精品在线观看免费| 精品久久久久久无| 久久精品国产免费| 欧美一区二视频| 视频一区视频二区中文| 欧美电影影音先锋| 免费在线观看视频一区| 日韩一二三区不卡| 美女免费视频一区| 久久午夜色播影院免费高清| 国产一区二区三区四区在线观看| xf在线a精品一区二区视频网站| 看国产成人h片视频| 精品成人免费观看| 韩国v欧美v亚洲v日本v| 欧美经典一区二区| 91香蕉视频mp4| 亚洲成人久久影院| 欧美一区二区三区日韩| 久久99精品网久久| 国产精品人成在线观看免费| 99re热视频这里只精品| 一区二区三区中文字幕电影 | 日韩欧美一级片| 麻豆久久久久久久| 久久精品亚洲麻豆av一区二区| 国产制服丝袜一区| 1024国产精品| 欧美日韩一区二区三区四区五区| 日韩国产欧美在线播放| 国产欧美日韩另类视频免费观看| 成人a免费在线看| 亚洲一区二区三区爽爽爽爽爽| 56国语精品自产拍在线观看| 国产露脸91国语对白| 中文字幕一区二区三区四区| 欧美特级限制片免费在线观看| 蜜臀av性久久久久蜜臀aⅴ| 国产午夜精品美女毛片视频| 91国产成人在线| 黑人巨大精品欧美黑白配亚洲| 国产精品每日更新| 制服丝袜日韩国产| 91首页免费视频| 麻豆高清免费国产一区| 自拍偷拍欧美激情| 欧美tk丨vk视频| 色久优优欧美色久优优| 国产一区视频导航| 婷婷成人激情在线网| 国产视频不卡一区| 日韩午夜激情免费电影| 91丝袜国产在线播放| 国产综合一区二区| 亚洲成av人片在线| 亚洲视频一二区| 久久久美女艺术照精彩视频福利播放| 欧美色网站导航| av一区二区三区| 国模大尺度一区二区三区| 午夜精品影院在线观看| 综合久久久久久| 国产色婷婷亚洲99精品小说| 日韩欧美在线一区二区三区| 欧美日韩一区二区在线观看视频| 国产成人综合亚洲91猫咪| 日本欧美韩国一区三区| 一区二区三区高清不卡| 国产精品激情偷乱一区二区∴| 精品粉嫩超白一线天av| 欧美一卡二卡三卡| 欧美一区二区三区在线观看| 欧美色精品在线视频| 91福利视频久久久久| 91网站在线播放| 91亚洲精品久久久蜜桃| 99久久国产综合色|国产精品| 国产宾馆实践打屁股91| 韩国欧美国产一区| 国内久久婷婷综合| 加勒比av一区二区| 国产精品一区二区果冻传媒| 极品少妇xxxx精品少妇| 狠狠v欧美v日韩v亚洲ⅴ| 精品一区二区av| 国产精品911| 国产91精品免费| www.亚洲免费av| 97国产一区二区| 欧美在线观看你懂的| 欧美性猛交xxxx黑人交 | 蜜桃视频一区二区三区在线观看| 亚洲国产精品一区二区久久恐怖片| 亚洲影视资源网| 天天色天天操综合| 久久99热国产| 国产成人精品免费在线| 成人深夜福利app| 色系网站成人免费| 欧美剧情片在线观看| 欧美成人bangbros| 久久日韩精品一区二区五区| 国产精品网站一区| 亚洲国产中文字幕在线视频综合| 婷婷成人激情在线网| 国产一区二区三区美女| 99视频一区二区| 欧美日韩一区二区三区不卡| 欧美va天堂va视频va在线| 国产精品成人网| 视频一区中文字幕国产| 国产精品一区二区三区四区| 91啪在线观看| 日韩精品在线一区二区| 中文字幕一区二区日韩精品绯色| 夜夜操天天操亚洲| 国产一区二区成人久久免费影院 | 91最新地址在线播放| 欧美视频一区二| www国产精品av| 亚洲第一会所有码转帖| 国产精品综合在线视频| 欧美三级一区二区| 国产欧美一区在线| 偷拍日韩校园综合在线| 波多野结衣中文一区| 91精品欧美一区二区三区综合在 |