{"id":3551,"date":"2020-12-10T14:25:43","date_gmt":"2020-12-10T05:25:43","guid":{"rendered":"https:\/\/androiphone.uvs.jp\/?p=3551"},"modified":"2020-12-10T14:27:45","modified_gmt":"2020-12-10T05:27:45","slug":"libgdx-scene2d%e3%81%a7%e3%81%aelabel%e3%81%ae%e6%96%87%e5%ad%97%e3%82%b5%e3%82%a4%e3%82%ba%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6","status":"publish","type":"post","link":"https:\/\/androiphone.uvs.jp\/?p=3551","title":{"rendered":"[libgdx] scene2D\u3067\u306eLabel\u306e\u6587\u5b57\u30b5\u30a4\u30ba\u306b\u3064\u3044\u3066"},"content":{"rendered":"<p>libgdx\u3092\u89e6\u308a\u59cb\u3081\u3066\u307e\u3042\u307e\u3042\u6163\u308c\u3066\u304d\u305f\u306e\u3067\u4e00\u3064\u8a18\u4e8b\u306b\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>Label\u3092\u751f\u6210\u3059\u308b\u3068\u304d\u306b\u306f<\/p>\n<pre class=\"lang:java decode:true\">        FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();\r\n        parameter.characters = \"hogehoge\";\r\n        parameter.size = 50;\r\n        BitmapFont label_font = game.font_gen.generateFont(parameter);\r\n\r\n\r\n        Label.LabelStyle labelStyle = new Label.LabelStyle(label_font, Color.WHITE);\r\n        Label title = new Label(\"hogehoge\", labelStyle);<\/pre>\n<p>\u4e0a\u306e\u3088\u3046\u306a\u30b3\u30fc\u30c9\u3067\u751f\u6210\u3057\u307e\u3059\u3002\u3044\u304d\u306a\u308agame\u3068\u304b\u51fa\u3066\u304d\u3066\u30a4\u30df\u30d5\u306a\u306e\u3067\u3056\u3063\u304f\u308a\u8aac\u660e\u3059\u308b\u3068<\/p>\n<p>Android\u30a2\u30d7\u30ea\u306e\u5834\u5408<\/p>\n<ol>\n<li>AndroidLauncher(AndroidApplication\u3092\u7d99\u627f\u3057\u305fActivity\u307f\u305f\u3044\u306a\u3082\u306e)\u306e\u30ed\u30fc\u30c9<\/li>\n<li>Game\u30af\u30e9\u30b9\u306e\u30ed\u30fc\u30c9<\/li>\n<li>Screen\u30af\u30e9\u30b9\u306e\u30ed\u30fc\u30c9<\/li>\n<\/ol>\n<p>\u306e\u9806\u3067\u30ed\u30fc\u30c9\u3055\u308c\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p>\u30de\u30eb\u30c1\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u3067\u4f5c\u308b\u3068\u304d\u30011\u306f\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u3067\u5909\u308f\u308b\u306e\u3067\u3001\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u306b\u4f9d\u5b58\u3057\u306a\u3044\u3088\u3046\u306b\u6a5f\u80fd\u3092\u5b9f\u88c5\u3059\u308b\u5834\u5408\u306fGame\u30af\u30e9\u30b9\u4ee5\u964d\u306b\u5b9f\u88c5\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u307e\u305f\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u306b\u4f9d\u5b58\u3057\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u6a5f\u80fd(TTS\u306a\u3069)\u306f1\u306b\u5b9f\u88c5\u3057\u3066\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u306b\u4e92\u63db\u3092\u6301\u305f\u305b\u308b\u306a\u3069\u306e\u5de5\u592b\u304c\u5fc5\u8981\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u540c\u3058\u30d5\u30a9\u30f3\u30c8\u3092\u751f\u6210\u3059\u308b\u306e\u3067\u3042\u308c\u3070\u30ab\u30b9\u30bf\u30e0\u3057\u305fGame\u30af\u30e9\u30b9\u3084\u30d9\u30fc\u30b9\u306eScreen\u30af\u30e9\u30b9\u3067\u7ba1\u7406\u3057\u305f\u307b\u3046\u304cdispose\u5fd8\u308c\u306b\u3088\u308b\u30ea\u30fc\u30af\u3092\u9632\u6b62\u3067\u304d\u307e\u3059\u3002libgdx\u3067\u306fttf\u306a\u3069\u306e\u30d5\u30a9\u30f3\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u76f4\u63a5\u6271\u3046\u306b\u306f\u30a8\u30af\u30b9\u30c6\u30f3\u30b7\u30e7\u30f3\u304c\u5fc5\u8981\u3068\u306a\u308b\u306e\u3067\u3001\u3042\u3089\u304b\u3058\u3081\u8a2d\u5b9a\u304c\u5fc5\u8981\u3067\u3059\u3002\u5177\u4f53\u7684\u306b\u306f\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u751f\u6210\u6642\u306eExtention\u306e\u8a2d\u5b9a\u3067Freetype\u306b\u30c1\u30a7\u30c3\u30af\u3092\u5165\u308c\u308b\u3068\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/androiphone.uvs.jp\/wp-content\/uploads\/2020\/10\/SnapCrab_NoName_2020-10-24_10-56-34_No-00.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-3541\" src=\"https:\/\/androiphone.uvs.jp\/wp-content\/uploads\/2020\/10\/SnapCrab_NoName_2020-10-24_10-56-34_No-00-266x300.png\" alt=\"\" width=\"266\" height=\"300\" srcset=\"https:\/\/androiphone.uvs.jp\/wp-content\/uploads\/2020\/10\/SnapCrab_NoName_2020-10-24_10-56-34_No-00-266x300.png 266w, https:\/\/androiphone.uvs.jp\/wp-content\/uploads\/2020\/10\/SnapCrab_NoName_2020-10-24_10-56-34_No-00-907x1024.png 907w, https:\/\/androiphone.uvs.jp\/wp-content\/uploads\/2020\/10\/SnapCrab_NoName_2020-10-24_10-56-34_No-00-768x867.png 768w, https:\/\/androiphone.uvs.jp\/wp-content\/uploads\/2020\/10\/SnapCrab_NoName_2020-10-24_10-56-34_No-00.png 1348w\" sizes=\"auto, (max-width: 266px) 100vw, 266px\" \/><\/a><\/p>\n<p>\u5f8c\u304b\u3089\u3067\u3082\u8ffd\u52a0\u3067\u304d\u307e\u3059\u304c\u3001bulid.gragle\u306e\u4fee\u6b63\u304c\u5fc5\u8981\u3068\u306a\u308a\u307e\u3059\u3002\u4e0b\u3042\u305f\u308a\u304c\u53c2\u8003\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<div class=\"linkcard\"><div class=\"lkc-external-wrap\"><div class=\"lkc-unlink\"><div class=\"lkc-card\"><div class=\"lkc-info\"><div class=\"lkc-favicon\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.google.com\/s2\/favicons?domain=westplain.sakuraweb.com\" alt=\"\" width=\"16\" height=\"16\" \/><\/div><div class=\"lkc-domain\">westplain.sakuraweb.com<\/div><\/div><div class=\"lkc-content\"><figure class=\"lkc-thumbnail\"><img decoding=\"async\" class=\"lkc-thumbnail-img\" src=\"https:\/\/s.wordpress.com\/mshots\/v1\/http%3A%2F%2Fwestplain.sakuraweb.com%2Ftranslate%2FlibGDX%2FExtensions%2FGdx%2520freetype.cgi?w=100\" width=\"100px\" height=\"108px\" alt=\"\" \/><\/figure><div class=\"lkc-title\">\u6d77\u5916\u88fd\u30e9\u30a4\u30d6\u30e9\u30ea\u30fbWeb API \u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306e\u7ffb\u8a33\u30da\u30fc\u30b8<\/div><div class=\"lkc-url\" title=\"http:\/\/westplain.sakuraweb.com\/translate\/libGDX\/Extensions\/Gdx%20freetype.cgi\"><strike>http:\/\/westplain.sakuraweb.com\/translate\/libGDX\/Extensions\/Gdx%20freetype.cgi<\/strike><\/div><\/div><div class=\"clear\"><\/div><\/div><\/div><\/div><\/div>\n<div class=\"linkcard\"><div class=\"lkc-external-wrap\"><a class=\"lkc-link no_icon\" href=\"https:\/\/github.com\/libgdx\/libgdx\/wiki\/Dependency-management-with-Gradle#freetypefont-gradle\" data-lkc-id=\"893\" target=\"_blank\" rel=\"external noopener\"><div class=\"lkc-card\"><div class=\"lkc-info\"><div class=\"lkc-favicon\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.google.com\/s2\/favicons?domain=github.com\" alt=\"\" width=\"16\" height=\"16\" \/><\/div><div class=\"lkc-domain\">GitHub<\/div><div class=\"lkc-share\"> <div class=\"lkc-sns-po\">525 Pockets<\/div><\/div><\/div><div class=\"lkc-content\"><figure class=\"lkc-thumbnail\"><img decoding=\"async\" class=\"lkc-thumbnail-img\" src=\"\/\/androiphone.uvs.jp\/wp-content\/uploads\/pz-linkcard\/cache\/6b63be61f959b055091d1d23449c200bcf11daeb6356d9e7bf9320d4a99d3266.jpeg\" width=\"100px\" height=\"108px\" alt=\"\" \/><\/figure><div class=\"lkc-title\">Dependency management with Gradle \u00b7 libgdx\/libgdx Wiki<\/div><div class=\"lkc-url\" title=\"https:\/\/github.com\/libgdx\/libgdx\/wiki\/Dependency-management-with-Gradle#freetypefont-gradle\">https:\/\/github.com\/libgdx\/libgdx\/wiki\/Dependency-management-with-Gradle#freetypefont-gradle<\/div><div class=\"lkc-excerpt\">Desktop\/Android\/HTML5\/iOS Java game development framework - Dependency management with Gradle \u00b7 libgdx\/libgdx Wiki<\/div><\/div><div class=\"clear\"><\/div><\/div><\/a><\/div><\/div>\n<p>\u79c1\u306f\u5148\u306b\u8a71\u3057\u305f\u901a\u308aGame\u30af\u30e9\u30b9\u306b\u5b9f\u88c5\u3057\u3066\u7ba1\u7406\u3057\u3066\u3044\u307e\u3059<\/p>\n<pre class=\"lang:default decode:true\">\/\/\u5171\u7528\u30d5\u30a9\u30f3\u30c8\u30b8\u30a7\u30cd\u30ec\u30fc\u30bf\u30fc\r\npublic FreeTypeFontGenerator mika_font_gen;\r\n\r\n\/\/\u5171\u7528\u30d5\u30a9\u30f3\u30c8\u30b8\u30a7\u30cd\u30ec\u30fc\u30bf\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5316\r\nmika_font_gen = new FreeTypeFontGenerator(Gdx.files.internal(ResourceFileManager.MIKA_FONT));\r\n\r\n<\/pre>\n<pre class=\"lang:default decode:true\">@Override\r\npublic void dispose() {\r\n\u3000\u3000\u3000super.dispose();\r\n\u3000\u3000\u3000assetManager.dispose();\r\n\u3000\u3000\u3000mika_font_gen.dispose();\r\n}<\/pre>\n<p>\u3067\u3001\u6700\u521d\u306eLabel\u306e\u751f\u6210\u306b\u623b\u308a\u307e\u3059\u304c\u3001\u3053\u306e\u6a19\u6e96\u306eLabel\u306fScale\u3092\u5909\u66f4\u3057\u3066\u3082\u53cd\u6620\u3055\u308c\u307e\u305b\u3093\u3002<\/p>\n<div class=\"linkcard\"><div class=\"lkc-external-wrap\"><a class=\"lkc-link no_icon\" href=\"https:\/\/stackoverflow.com\/questions\/42822867\/how-do-i-scale-a-label-in-libgdx\" data-lkc-id=\"894\" target=\"_blank\" rel=\"external noopener\"><div class=\"lkc-card\"><div class=\"lkc-info\"><div class=\"lkc-favicon\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.google.com\/s2\/favicons?domain=stackoverflow.com\" alt=\"\" width=\"16\" height=\"16\" \/><\/div><div class=\"lkc-domain\">Stack Overflow<\/div><\/div><div class=\"lkc-content\"><figure class=\"lkc-thumbnail\"><img decoding=\"async\" class=\"lkc-thumbnail-img\" src=\"\/\/androiphone.uvs.jp\/wp-content\/uploads\/pz-linkcard\/cache\/93927fc1e64dd3e5b86b87f2a89b3b29bc3a30e0e6b7a2312393a2a6226faaba.jpeg\" width=\"100px\" height=\"108px\" alt=\"\" \/><\/figure><div class=\"lkc-title\">How do i scale a Label in LibGdx<\/div><div class=\"lkc-url\" title=\"https:\/\/stackoverflow.com\/questions\/42822867\/how-do-i-scale-a-label-in-libgdx\">https:\/\/stackoverflow.com\/questions\/42822867\/how-do-i-scale-a-label-in-libgdx<\/div><div class=\"lkc-excerpt\">i am trying to code a HUD for my game but i cannot figure out how to scale a Label properly I am using this code:Label hpLabel = new Label(&quot;HP: &quot;,new Label.LabelStyle(new BitmapFont(),Color.BROWN...<\/div><\/div><div class=\"clear\"><\/div><\/div><\/a><\/div><\/div>\n<p>\u8abf\u3079\u305f\u3068\u3053\u308dsetFontScale\u3067\u5909\u66f4\u306f\u53ef\u80fd\u3067\u3059\u304c\u3001Debug\u67a0\u304c\u6b63\u3057\u304f\u8868\u793a\u3055\u308c\u306a\u3044\u3068\u304b\u4e0d\u90fd\u5408\u304c\u3042\u308a\u307e\u3059\u3002Group\u3092\u751f\u6210\u3057\u3066\u305d\u3053\u306bLabel\u3092\u5165\u308c\u308b\u65b9\u6cd5\u306f\u3044\u3044\u306e\u3067\u3059\u304c\u305d\u306e\u90fd\u5ea6Group\u3092\u751f\u6210\u3059\u308b\u306e\u3082\u9762\u5012\u306a\u306e\u3067MyLabel\u30af\u30e9\u30b9\u3092\u4f5c\u308a\u5e38\u7528\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true \">public class MyLabel extends Group {\r\n\r\n    private Label label;\r\n\r\n    public MyLabel(String msg , Label.LabelStyle labelStyle) {\r\n        super();\r\n\r\n        label = new Label(msg, labelStyle);\r\n        this.addActor(label);\r\n\r\n    }\r\n\r\n    @Override\r\n    public float getWidth() {\r\n        return label.getWidth()  * this.getScaleX() ;\r\n    }\r\n\r\n    @Override\r\n    public float getHeight() {\r\n        return label.getHeight()  * this.getScaleY() ;\r\n    }\r\n\r\n    @Override\r\n    public Actor debug() {\r\n        return label.debug();\r\n    }\r\n\r\n    @Override\r\n    public boolean remove() {\r\n        label.remove();\r\n        return super.remove();\r\n    }\r\n}<\/pre>\n<p>getWidth()\u3001getHeight()\u306f\u6b63\u3057\u3044\u5024\u3092\u8fd4\u3059\u305f\u3081\u306b\u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9\u3057\u3066\u3044\u307e\u3059\u3002\u3053\u308c\u3067\u4e00\u5fdc\u3001\u30b9\u30b1\u30fc\u30e9\u30d6\u30eb\u306a\u30e9\u30d9\u30eb\u3092\u751f\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3068\u304a\u3082\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>libgdx\u3092\u89e6\u308a\u59cb\u3081\u3066\u307e\u3042\u307e\u3042\u6163\u308c\u3066\u304d\u305f\u306e\u3067\u4e00\u3064\u8a18\u4e8b\u306b\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002 Label\u3092\u751f\u6210\u3059\u308b\u3068\u304d\u306b\u306f FreeTypeFontGenerator.FreeTypeFontParameter parameter = n [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3541,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_locale":"ja","_original_post":"https:\/\/androiphone.uvs.jp\/?p=3551","footnotes":""},"categories":[1],"tags":[],"class_list":["post-3551","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-1","ja"],"_links":{"self":[{"href":"https:\/\/androiphone.uvs.jp\/index.php?rest_route=\/wp\/v2\/posts\/3551","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/androiphone.uvs.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/androiphone.uvs.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/androiphone.uvs.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/androiphone.uvs.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3551"}],"version-history":[{"count":5,"href":"https:\/\/androiphone.uvs.jp\/index.php?rest_route=\/wp\/v2\/posts\/3551\/revisions"}],"predecessor-version":[{"id":3573,"href":"https:\/\/androiphone.uvs.jp\/index.php?rest_route=\/wp\/v2\/posts\/3551\/revisions\/3573"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/androiphone.uvs.jp\/index.php?rest_route=\/wp\/v2\/media\/3541"}],"wp:attachment":[{"href":"https:\/\/androiphone.uvs.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3551"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/androiphone.uvs.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3551"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/androiphone.uvs.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3551"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}