[Cocos Creator 강좌] RichText 사용하기

2017. 10. 19. 14:33· Frontend/Cocos Creator
목차
  1. Supported tags


RichText component reference 

 RichText component는 string을 다양한 스타일로 표현할 수 있게 해줍니다. 약간의 BBCode를 통해서 텍스트를 커스터마이징 할 수 있죠. Creator에서 제공하고 있는 태그는 다음과 같습니다. (color, size, outline, b, i, u, br, img) 기존 Label 컴포넌트로는 할 수 없었던 텍스트에 테두리(outline)을 만드는 것을 예제로 해보겠습니다.






1. Hierarchy 탭에 Create Empty Node를 만듭니다.










2. Add Componet - Add Renderer Component - RichText 











3. 생성된 RichText의 String 프로퍼티에 BBCode를 넣어줍니다. 사용 예시는 아래의 표를 참고하세요.








4. 위와 같이 리치텍스트가 적용된 것을 볼 수 있습니다.






Supported tags

Name

Description

Example

Note

color

Specify the font rendering color, the color value could be a built-in value or a hex value. eg, use #ff0000 for red.

<color=#ff0000>Red Text</color>

For built-in color, please refer to cc.Color

size

Specify the font rendering size, the size should be a integer.

<size=30>enlarge me</size>
outline

Specify the font 

outline

, you could customize the 

outline

 color and width by using the 

color

 and 

width

 attribute.

<outline color=red width=4>A label withoutline</outline>If you don't specify the color and width attribute, the default color value is #ffffff and the default width is 1.
bRender text as bold font<b>This text will be rendered as bold</b>The tag name must be lowercase and tag name bold is not supported.
iRender text as italic font<i>This text will be rendered as italic</i>The tag name must be lowercase and tag name italic is not supported.
uAdd a underline to the text<u>This text will have a underline</u>The tag name must be lowercase and tag name underline is not supported.
onSpecify a event callback to a text node,when you click the node,the callback will be triggered.<on click="handler"> click me! </on>Every valid tag could also add another click event attribute. eg. <size=10 click="handler2">click me</size>
brInsert a empty line<br/>Note:<br></br> and <br> are both invalid tags.
imgAdd image emoji support to your RichText. The emoji name should be a valid spriteframe name in the ImageAtlas property.<img src='emoji1' click='handler' />Note: Only <img src='foo' click='bar' /> is a valid img tag. If you specify a large emoji image, it will scale the sprite height to the line height of the RichText together with the sprite width.




반응형
저작자표시 (새창열림)

'Frontend > Cocos Creator' 카테고리의 다른 글

[Cocos Creator] ScrollView 개념 및 사용 예시  (2) 2018.01.29
[Cocos Creator] Decorator 사용하기  (0) 2018.01.04
[Cocos Creator] cc.Class 파헤치기  (0) 2017.11.21
[Cocos Creator] 생명주기 (Life Cycle)  (0) 2017.11.21
[Cocos Creator Animation] 1. Animation에 대하여  (0) 2017.10.27
[Cocos Creator 강좌] Label에 Dynamic Font 적용하기  (0) 2017.10.19
  1. Supported tags
'Frontend/Cocos Creator' 카테고리의 다른 글
  • [Cocos Creator] cc.Class 파헤치기
  • [Cocos Creator] 생명주기 (Life Cycle)
  • [Cocos Creator Animation] 1. Animation에 대하여
  • [Cocos Creator 강좌] Label에 Dynamic Font 적용하기
에반황
에반황
"어른이면서 애이기도 하고 싶다."
에반황
에반, 어른반
에반황
전체
오늘
어제
  • 전체보기 (118)
    • About (1)
    • Backend (5)
      • Django (3)
      • Spring (2)
    • Database (2)
      • 아키텍처 (0)
      • SQL (0)
      • Redis (2)
      • 코딩 테스트 (0)
      • 요구 사항 해결 (0)
    • Infra, Cloud (0)
      • AWS (0)
      • GoCD (0)
      • Docker (0)
      • Kubernetes (0)
      • Mesos Marathon (0)
    • Basic (34)
      • C (1)
      • C# (4)
      • C++ (1)
      • Java (9)
      • Javascript (6)
      • Typescript (5)
      • GO (0)
      • Python (4)
      • 프로그래밍 기초 (1)
      • 게임 디자인 패턴 (1)
      • 운영체제 (0)
      • 알고리즘 (2)
      • 자료구조 (0)
    • Computer Science (0)
    • Frontend (74)
      • Swift (1)
      • Unity (31)
      • Android (13)
      • Vue.js (2)
      • Phaser (1)
      • Cocos2D JS (2)
      • Cocos Creator (16)
      • Facebook Instant Game (8)
반응형

인기 글

최근 댓글

hELLO · Designed By 정상우.v4.2.2
에반황
[Cocos Creator 강좌] RichText 사용하기
상단으로

티스토리툴바

단축키

내 블로그

내 블로그 - 관리자 홈 전환
Q
Q
새 글 쓰기
W
W

블로그 게시글

글 수정 (권한 있는 경우)
E
E
댓글 영역으로 이동
C
C

모든 영역

이 페이지의 URL 복사
S
S
맨 위로 이동
T
T
티스토리 홈 이동
H
H
단축키 안내
Shift + /
⇧ + /

* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.