看看这个怎么就指向空了
- Java code
public Engine onLoadEngine() { this.mFontTexture = new Texture(256, 256, TextureOptions.BILINEAR_PREMULTIPLYALPHA); this.mDroidFontTexture = new Texture(256, 256, TextureOptions.BILINEAR_PREMULTIPLYALPHA); this.mStrokeFontTexture = new Texture(256, 256, TextureOptions.BILINEAR_PREMULTIPLYALPHA); // 定义默认字体,其中的参数:第一个为上面定义的纹理,第二个为字体样式,第三个为字体大小,第四个为是否消锯齿,第五个为颜色 this.mFont = new Font(this.mFontTexture, Typeface.create(Typeface.DEFAULT, Typeface.BOLD), 32, true, Color.BLACK); fontList.add(this.mFont); // 自定义的字体,其中的参数:第一个为上面定义的纹理,第二个为本context,第三个为字体的路径,第四个为字体的大小,第五个为是否消锯齿,第六个为颜色 this.iFont = FontFactory.createFromAsset(this.mDroidFontTexture, this, "Droid.ttf", 32, true, Color.BLACK); fontList.add(this.iFont); // 定义字体的描边,其中的参数:第一个参数为上面定义的纹理,第二个参数为字体样式,第三个参数为字体的大小,第四个参数为是否消锯齿,第五个参数为字体颜色,第六个参数为字体边的宽度,第七个参数为秒边的颜色 this.mStrokeFont = new StrokeFont(this.mStrokeFontTexture, Typeface.create(Typeface.DEFAULT, Typeface.BOLD), 32, true, Color.BLACK, 2, Color.WHITE); fontList.add(this.mStrokeFont); // 加载三种纹理 [color=#FF0000]this.mEngine.getTextureManager().loadTextures(this.mFontTexture, this.mDroidFontTexture, this.mStrokeFontTexture);[/color] // 加载三种字体 this.mEngine.getFontManager().loadFonts(this.mFont, this.iFont, this.mStrokeFont); return mEngine; }这里运行到红字的地方会出错, java.lang.RuntimeException: Unable to start activity ComponentInfo
为什么会这样啊,没有空的东西啊
[解决办法]
觉的问题在于你在没有onLoadEngine完,就用mEngine去加载资源了,我觉的应该这个mEngine是空值