All Projects → dingjibang → GDX-lazy-font

dingjibang / GDX-lazy-font

Licence: other
auto self-generate BitmapFont for libgdx 1.5.0 +

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to GDX-lazy-font

Gdx Rpg
java & libgdx制作的RPG游戏! an RPG by java and LibGDX
Stars: ✭ 239 (+819.23%)
Mutual labels:  libgdx
Koru
A 2D multiplayer sandbox game.
Stars: ✭ 78 (+200%)
Mutual labels:  libgdx
pixelwheels
A top-down retro racing game for PC (Linux, macOS, Windows) and Android.
Stars: ✭ 315 (+1111.54%)
Mutual labels:  libgdx
EasyStage
A stage profile tool for libgdx
Stars: ✭ 17 (-34.62%)
Mutual labels:  libgdx
ark-pixel-font
Open source Pan-CJK pixel font / 开源的泛中日韩像素字体
Stars: ✭ 1,767 (+6696.15%)
Mutual labels:  bitmap-font
monobit
Tools for working with monochrome bitmap fonts
Stars: ✭ 124 (+376.92%)
Mutual labels:  bitmap-font
Gdx Pay
A libGDX cross-platform API for InApp purchasing.
Stars: ✭ 195 (+650%)
Mutual labels:  libgdx
rocket-lazy-load
Standalone LazyLoad plugin for WordPress (based on WP Rocket)
Stars: ✭ 25 (-3.85%)
Mutual labels:  lazy-loading
ForgE
Simple clone of RPG maker using LibGdx
Stars: ✭ 17 (-34.62%)
Mutual labels:  libgdx
kickoff
Open Kick-Off is a fun rewriting attempt of the cult football game Kick Off 2 designed by Dino Dini and released in 1990 by Anco for the Atari ST and the Commodore Amiga. It is written in Java with the help of libGDX.
Stars: ✭ 32 (+23.08%)
Mutual labels:  libgdx
DoubleHelix
A live wallpaper and daydream for Android featuring stylized glassy-looking DNA structures
Stars: ✭ 86 (+230.77%)
Mutual labels:  libgdx
vitext
The Next.js like React framework for better User & Developer experience!
Stars: ✭ 376 (+1346.15%)
Mutual labels:  lazy-loading
guide-to-async-components
📖 Guide To JavaScript Async Components
Stars: ✭ 79 (+203.85%)
Mutual labels:  lazy-loading
Martianrun
An Open-Source Running Game with libGDX
Stars: ✭ 242 (+830.77%)
Mutual labels:  libgdx
lazy-load-images.js
Progressive & lazy loading images.
Stars: ✭ 17 (-34.62%)
Mutual labels:  lazy-loading
Destinationsol
Official continuation of Destination Sol, the great fun little arcade space shooter from http://sourceforge.net/projects/destinationsol/ Modules live at https://github.com/DestinationSol/
Stars: ✭ 214 (+723.08%)
Mutual labels:  libgdx
tripeaks-gdx
A simple tri peaks solitaire game using libGDX.
Stars: ✭ 45 (+73.08%)
Mutual labels:  libgdx
angular-image-loader
A simple progressive, responsive, lazy image and video loading library for Angular that detects browser size and loads the appropriate image or video only when the element is in viewport. This package requires @thisissoon/angular-inviewport
Stars: ✭ 21 (-19.23%)
Mutual labels:  lazy-loading
gdx-gameanalytics
Gameanalytics.com client implementation for libGDX
Stars: ✭ 28 (+7.69%)
Mutual labels:  libgdx
generator-angular-lazy
Yeoman generator for creating Angular applications which lazy load components as needed at runtime. Based on SystemJS, JSPM, Babel and Gulp.
Stars: ✭ 33 (+26.92%)
Mutual labels:  lazy-loading

GDX-LAZY-FONT

智能且懒加载的BitmapFont模块。
Auto generate & manage your bitmapfont without pre-generate.

Introduce & demo in English ,click me.

下载地址-Download

点我下载最新版,click me to download last release

注意:1.9的libgdx在文字绘制部分的API有些小改动,如果你需要针对1.9版本的GDX,请在下载页面专门选择1.9那个版本,否则就使用他下面那个正常的版本!

NOTICE<< GDX1.9 has some API change for render text,please notice the version on download page


介绍 & 使用方法

这是LibGDX的一个第三方小组件,他轻巧的只有140行不到的代码,但或许能帮助你大忙( •́ .̫ •̀ )

介绍

众所周知,LibGDX的文字模块对非英语地区支持的并不是很好(虽然现在已经好多了)。

为什么说对非英语地区支持不好呢?首先英语就那几个字母,加上标点符号之类,总共的字符也就100个左右,而我们可怜的libgdx并没有文字纹理的管理方案,我们使用libgdx绘制文字时,要先声明且创建文字的“纹理”,然后才能画到屏幕上,麻烦的一逼好么?!而前面说过,英语就100多个字符,可以在程序加载时候都先声明好纹理然后随便用,但我们汉语乱七八糟的字符要成千上万个,不可能在程序载入时候都加载进来,否则别人的手机或者显卡就要爆掉了= = 所以我们要每次使用文字的时候,先创建个什么鬼generator,然后生成所要文字的纹理,然后在画上去,这非常的麻烦而且精神污染,于是这个项目就产生了( ̄∀ ̄)

这个项目主要是支持我正在开发的一款角色扮演游戏(见我仓库里的“GDX-RPG”项目),他的作用是完全的字体纹理自我加载和管理,不用generator去一遍遍生成纹理,想在屏幕画什么字就画什么字,爽到爆~

这个LazyFont项目以前就有了,只不过以前是针对LibGDX1.5版本以下的,因为我自己写的项目也只是用1.4.1版本的,所以这个git项目创建了之后就没太更新过。 前两天痛下狠心把1.4.1版本升级到了最新的1.7.0(当然来自未来的你那时候的GDX版本可能更高了)

然后你懂的各种报错红叉叉让我痛不欲生(╯ ̄Д ̄)╯
其中最大的问题就是文字模块,1.4和1.7的GDX中,文字核心绘制方法已经变得很多了,我以前写的一些中文绘制辅助类也早就用不了了,于是打算重新研究下这个项目。
(不要问我为什么不更新这个项目了,因为这项目已经写完了啊,除非libgdx有什么大变动不然可以随便用,我会持续关注并且更新的)

废话少说,本项目的作用& 好处有什么?

1.全自动的生成BitmapFont,无需手动generate,适合大量文字应用的场景(服务器公告、文字冒险游戏等)。
(那啥,总有人问我,这个东西影不影响性能,我只想说,可以告诉你,用了这个组件,只会多出连0.1%的CPU占用都不到而已,请不要成天跟我性能性能的了,你特么做个消灭星星也要性能,我也是笑的前列腺液都出来了)
2.支持BitmapFont.draw(),也支持所有需要调用font的地方(如Scene2d.ui.Label这个类)。
3.不污染代码,即插即用,理论来说以后的GDX只要更新不是太猛,基本都能兼容(不兼容1.4以下版本,如果你想要1.4以下的,看一下本项目的历史记录自己找吧)。

使用方法

你可以直接下载jar包,然后导入到你的项目里,或者拷贝源代码。

要创建一个LazyBitmapFont,你需要一个FreeTypeFontGenerator,且只需要一个,你可以创建一个FreeTypeFontGenerator变量用到游戏结束。

lazyBitmapFont = new LazyBitmapFont(FreeTypeFontGenerator generator, int fontSize);

其中,generator就是上面说的变量,你只需要全局new一个这个变量,就可以给所有的LazyBitmapFont或者你自己的需求使用了。 然后,fontSize顾名思义,就是文字的大小了。遗憾的是,本组件不能动态的更改文字大小,也就是说一旦new了一个本组件,就只能使用一种文字大小了,如果你需要好几种字号,那么就分别多new几个不同字号的本组件吧(每个组件都很轻量,不会占资源的~

接着,没了,是的,没了( •́ .̫ •̀ )

你可以直接调用下面代码试一下:

lazyBitmapFont.draw(batch, "我随便说一句话就能够组成十五字", 100, 200);

看看,屏幕上有没有字出来呢?

同理,你也可以弄一个label试试:

//创建...
LabelStyle style = new LabelStyle();
style.font = lazyBitmapFont;

Label label = new Label("我就随便打句话",style);

Stage stage = new Stage();
stage.addActor(label);

// 渲染...
stage.act();
stage.draw();

//或者试试在运行时候把label的文字改掉...
label.setText("在运行时候随便的更改下文字!");

好了,就是这么简单,除了new的时候和原版不同以外,其他都是一模一样的,而且再也不用换一句文本就重新generate一下啦,就是这么酸爽!

当然,最后用完了也别忘了dispose()掉哦。

lazyBitmapFont.dispose();

下面是一模一样的英文版介绍,不用看了,赶紧去试试吧。

what & how to

what's this?

LazyBitmapFont is an auto and self-texture-gengrate bitmapFont extend, you can draw any text without generator. And it's helpful for no English-base language to manage BitmapFont.

how to use it

First, download jar file and import to your project, or copy source.

You need a FreeTypeFontGenerator to create this extend, like:

lazyBitmapFont = new LazyBitmapFont(FreeTypeFontGenerator generator, int fontSize);

the fontSize is final variable that you can't modify at runtime. Of course you can create some different size object.

Then ,this API is same as BitmapFont.

lazyBitmapFont.draw(batch, "我随便说一句话就能够组成十五字", 100, 200);

or create a Label as usual as before:

//create...
LabelStyle style = new LabelStyle();
style.font = lazyBitmapFont;

Label label = new Label("我就随便打句话",style);

Stage stage = new Stage();
stage.addActor(label);

// render...
stage.act();
stage.draw();

//or change text at runtime...
label.setText("在运行时候随便的更改下文字!");

final, use dispose() to dispose this.

 lazyBitmapFont.dispose();
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].