看博客学学Android(二十一)

原文地址:

Day 19: Daily Challenge and Missions

Daily challenge is to collect 5 letter which fly like powerups do. Once you collect them all, you get some coins to buy powerups. This is a way to get easy free coins just by playing the game. I was inspired by Subway Surfers when creating this.

Missions are various tasks for player to complete to earn coins. Coins are used to buy upgrades and expendable items like shields, bombs, etc. Missions come in sets of three, and you need to complete all three tasks to earn the reward.

Daily challenge, collect letters

For the missions I figured that it would be easiest to use the builtin multiline text wrapping. However, the line height is too big, and I could'n find a way to reduce it. At least, not from code. Then I edited the .fnt file generated by BMFont and just changed

lineHeight=33

to

lineHeight=23

I added 5 pixels of drop shadow around all letters after the bitmap was generated initially, so I'm now reducing height by ten (5 pixels above, and 5 below the glyph).

While searching the docs for this, I found something else I missed before: Depending on the font you choose for the game, numbers might not look very nice as glyph for digit "one" can we very slim, and numbers like 11 look odd. To solve this, you can fix some of the glyphs in the font to use fixed width:

font.setFixedWidthGlyphs("0123456789");

This looks really good, but I already did some design decisions that used the slim-glyphs "feature", so I'm not going to use this.

 

Day 19: Daily Challenge and Missions

19天:日常挑战任务

日常的挑战是收集5个像道具一样飞翔的文字。一旦你收集够全部,你将获得一些金币,可以用来购买道具。这样仅仅通过玩游戏,就可以很容易的获得免费的金币。这样的灵感来自于地铁跑酷。

任务系统是通过完成各种各样的任务来争取金币。金币可以用来升级和一些像盾牌、炸弹这样的消耗品。任务系统每次会安排三个,你必须完成所有的三个任务才能获得报酬

Daily challenge, collect letters

为了是任务看起来很华丽,我很容易就使用了多行文字来进行构件。但是,行高太大了,而且我还不能减小。至少,无法通过代码实现。所以我编辑了通过BMFont生成的.fnt文件,仅仅是如下改变

lineHeight=33

to

lineHeight=23

在所有字母的初始化位图处,我加了5像素的阴影。所以我现在要减少十的高度(上下各5像素)。

当我因为这个查阅文档的时候,我发现了之前我错过的一些东西:根据你游戏选择的字体,数字可能不会显示的太好,比如象形文字数字“1”可能会非常的细长,而数字“11”看起来又很零散。为了解决这个问题,你可以通过固定字体的宽度来实现:

font.setFixedWidthGlyphs("0123456789");

这看起来很好,但是我已经决定使用纤细的样式了,所以我不打算用这个。

转载于:https://www.cnblogs.com/NorthDrift/p/3438350.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值