wise9 / enchant.js

A simple JavaScript framework for creating games and apps
http://enchantjs.com
MIT License
1.69k stars 314 forks source link

enchant.Label Error: New line characters <br/>, \n, \r don't work on enchant.Label! #297

Closed phongvcao closed 9 years ago

phongvcao commented 9 years ago

Hi guys,

I am trying to create an enchant.Label that can spread multiple lines. However, it seems that the normal
, \n, \r characters don't work with enchant.Label?

I have taken a look at enchant.js source code and saw that enchant.Label split() its String content using the
tag. However, despite inserting
tag in the middle of the String passed to enchant.Label(), my enchant.Label is still one-line instead of multiple lines. I have been scratching my head for several hours now and still cannot figure out the way to achieve this.

Does anyone know how to fix this issue or how to create a multiple-lines enchant.Label? All answers are appreciated!

GotAnySnacks commented 9 years ago

Do you mind giving an example of the string you're using for the label's .text property? I haven't had a problem using br in the past.

rtsan commented 9 years ago

Label uses br tag to line breaking. Valid formats of tag are "<br>", "<br/>" and "<br />". (uppercase are also valid).

phongvcao commented 9 years ago

Hi guys,

Nevermind it was working again. However, I feel like enchant.js should have a way to allow CSS positioning & styling of elements such as labels or text in dialog, etc.. I will be working on an enchant plugin like that when I have time. Thank you for all your support :D