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

📄 c2bab742b99d001c1557a899b06c072e

📁 用J2ME实现的
💻
字号:
/*
 *  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
*/
package org.piratis.j2me.demos.jumping;

import javax.microedition.lcdui.Image;

import org.piratis.j2me.core.game.Canvas;
import org.piratis.j2me.core.game.Engine;
import org.piratis.j2me.core.game.Sprite;
import org.piratis.j2me.core.game.TiledLayer;


/**
 * TODO add JumpingEngine description
 * 
 * @author		Jordi Mart韓
 * @copyright	Copyright (c) 2003-2004
 * @created 	25-jun-2004
 * @version		$Id: JumpingEngine.java,v 1.10 2004/07/22 16:52:05 piratis Exp $
 */

public class JumpingEngine 
	extends Engine
{
    private Sprite mouth1, mouth2;
    private TiledLayer tile;
    private int commonTile;
    /**
     * @param canvas
     */
    public JumpingEngine(Canvas canvas)
    	throws Exception
    {
        super(canvas);
        
        // load bouncing ball
        Sprite spr = new Sprite(Image.createImage("/jumping/jumping.png"));
        spr.setVisible(true);
        spr.moveTo(50, 50);
        this.layers.add(spr);
        
        // animate mouth
        mouth1 = new Sprite(Image.createImage("/jumping/mouth.png"), 40, 36);
        mouth1.setVisible(true);
        this.layers.add(mouth1);
        
        // custom animate mouth
        mouth2 = new Sprite(Image.createImage("/jumping/mouth.png"), 40, 36);
        mouth2.setVisible(true);
        mouth2.setFrameSequence(new int[]{0,0,0,1,1,1,2,2,2,2,2,2});
        mouth2.moveTo(0,40);
        this.layers.add(mouth2);
        
        // tile
        this.tile = new TiledLayer(4, 4,
                Image.createImage("/jumping/tiles.png"), 32, 32);
        this.tile.fillCells(0, 0, 4, 4, 1);
        this.tile.fillCells(1, 1, 2, 2, 2);
        // set 'common' (animated tile)
        this.commonTile = tile.createCommonTile(1);
        this.tile.setCell(3, 3, this.commonTile);
        this.tile.setVisible(true);
        this.tile.moveTo(0, 0);
        this.layers.add(tile);
        
        // window
        this.layers.setWindow(0, 0, canvas.getWidth(), canvas.getHeight());
    }

    /* (non-Javadoc)
     * @see org.piratis.j2me.core.game.Engine#work()
     */
    protected void work()
    {
        mouth1.nextFrame();
        mouth2.nextFrame();
        
        tile.setCommonTile(this.commonTile, 
                ((tile.getCommonTile(this.commonTile)+1) % 3));
    }

    /* (non-Javadoc)
     * @see org.piratis.j2me.core.game.Engine#input()
     */
    protected void input()
    {
        // TODO Auto-generated method stub
        
    }

}

⌨️ 快捷键说明

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