text

来源:互联网 发布:java里 try 编辑:程序博客网 时间:2024/06/09 20:14
Text

TextExampleText textCenter = newText(100, 60, this.mFont,"Hello AndEngine!\nYou can even have multilined text!", HorizontalAlign.CENTER);这句就生成一个Text对象在屏幕上显示文字,是居中对齐。当然生成后得scene.attachChild(textCenter);才有用。注意Load的时候,Font的生成方法:

this.mFontTexture= newBitmapTextureAtlas(256, 256, TextureOptions.BILINEAR_PREMULTIPLYALPHA);

             this.mFont= newFont(this.mFontTexture, Typeface.create(Typeface.DEFAULT, Typeface.BOLD), 32,true, Color.BLACK);

             this.mEngine.getTextureManager().loadTexture(this.mFontTexture);

      this.getFontManager().loadFont(this.mFont);

 

TickerTextExample:逐字动画显示。newTickerText最后的参数就是显示的速度。对TextregisterEntityModifier注册一个并行的Modifier使其边缩放边改变透明度(ScaleModifierAlphaModifier)。setBlendFunction设置Blend方式。

 

ChangeableText:前两者都是内容固定的Text。可变的用newChangeableText就可以了。本例另一个有价值的部分是帧率的取得:1.FPSCounter作为UpdateHandler注册到引擎里。2.Scene里注册个TimerHandleronTimePassed事件里改变ChangeableText的内容。论坛上解释在Scene里和GameEngine里注册UpdateHandler是一个效果。

 

CustomFontExample:自定义字体。FontFactory.setAssetBasePath,,FontFactory.createFromAsset,this.getFontManager().loadFonts像生成图片asset那样生成字体。New Text的时候设置字体。

 

StrokeFontExample:字体描边。Font:普通字体类。StrokeFont:描边字体类。各种参数参考代码吧。

原创粉丝点击