AndEngine001——andengine.jar版本的问题

    andengine.jar发展了好多的版本,所以当你发现没有你所看源代码中的函数时,可以尝试去找找其他版本的jar,应该很容就能解决呢。

    稍后附上自己搜集的压缩包。


压缩包下载


作为入门,个人建议用其中的01,并用本系列教程002中的代码模仿,也可用下边的例子模仿学习。

例子来源:http://blog.csdn.net/cping1982/article/details/6227775


package com.example.hello;

import org.anddev.andengine.engine.Engine;
import org.anddev.andengine.engine.camera.Camera;
import org.anddev.andengine.engine.options.EngineOptions;
import org.anddev.andengine.engine.options.EngineOptions.ScreenOrientation;
import org.anddev.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy;
import org.anddev.andengine.entity.scene.Scene;
import org.anddev.andengine.entity.text.ChangeableText;
import org.anddev.andengine.entity.util.FPSLogger;
import org.anddev.andengine.opengl.font.Font;
import org.anddev.andengine.opengl.texture.Texture;
import org.anddev.andengine.opengl.texture.TextureOptions;
import org.anddev.andengine.ui.activity.BaseGameActivity;

import android.graphics.Color;
import android.graphics.Typeface;
import android.util.Log;

public class MainActivity extends BaseGameActivity
{
	private String TAG = "zhang";
	private static final int CAMERA_WIDTH = 320;
    private static final int CAMERA_HEIGHT = 480;
    private Camera andCamera;
    private Texture myFontTexture;
    private Font myFont;
	public void onLoadComplete()
	{
		// TODO Auto-generated method stub
		
	}
	public Engine onLoadEngine()
	{
		// TODO Auto-generated method stub
		//return null;
		andCamera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
		return new Engine(new EngineOptions(true, ScreenOrientation.PORTRAIT, 
				new RatioResolutionPolicy(CAMERA_WIDTH,CAMERA_HEIGHT), andCamera));
	}
	public void onLoadResources()
	{
		// TODO Auto-generated method stub
		//构建一个纹理用以显示文字
		myFontTexture = new Texture(256,256,TextureOptions.DEFAULT);
		// 构建字体
		myFont = new Font(myFontTexture, 
				Typeface.create(Typeface.DEFAULT, Typeface.BOLD), 
				32, true, Color.WHITE);
		// 注入相关纹理及字体
		mEngine.getTextureManager().loadTexture(myFontTexture);
		mEngine.getFontManager().loadFont(myFont);
	}
	public Scene onLoadScene()
	{
		// TODO Auto-generated method stub
		//return null;
		// 构建场景,允许的最大Layer数量为1
		final Scene scene = new Scene(1);
		// 使用可以变更内容的ChangeableText显示FPS(它的父类Text不允许改变显示内容),位置在15,5,  
        // 字体为myFont中所规定的,最多允许显示5个字符(设置能显示几个字符,实际就能显示几个,  
        // AndEngine不能自动扩充,不填以初始化时输入的字符数计算……)
		final ChangeableText text = new ChangeableText(5, 5, myFont, "0.0", 5);
		// 注册FPS监听
		mEngine.registerUpdateHandler(new FPSLogger()
		{
			protected void onHandleAverageDurationElapsed(final float pFPS)
			{
				super.onHandleAverageDurationElapsed(pFPS);
				// 传递内容到ChangeableText
				text.setText("" + pFPS);
				Log.v(TAG, ""+pFPS);
			}
			
		});
		// 将ChangeableText注入场景
		scene.attachChild(text);
		// 构建场景,可容纳图层数为1
		return scene;
	}
    
    
}


你可能感兴趣的:(String,jar,Class,float,layer)