Coder Social home page Coder Social logo

gabrielnica / bitmapglyphlabel Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 13 KB

Swift package for creating SpriteKit labels using bitmap fonts generated by BMFont xml format compatible apps such as BMGlyph, BMFont and Glyph Designer 2

License: MIT License

Swift 100.00%

bitmapglyphlabel's Introduction

BitmapGlyphLabel

This is a Swift package for creating SpriteKit labels using bitmap fonts generated by BMFont xml format compatible apps such as BMGlyph, BMFont and Glyph Designer 2

Usage

  1. add the package to your project through Xcode or by editing your Package.swift file and adding: .package(url: "https://github.com/gabrielnica/bmglyph-swift.git", from: "1.0.0")
  2. import the library import BitmapGlyphLabel
  3. create a font object
let font = BitmapGlyphFont(named: "myFont")

or

let cachedAtlas = ...
let font = BitmapGlyphFont(named: "myFont", usingAtlas: cachedAtlas)

if you already loaded the atlas in memory for caching purposes. It is recommended to also store the font for future use

  1. create a label node add it to your scene
let labelNode = BitmapGlyphLabel(text: "Some text", font: font)

self.addChild(labelNode)

By default the text is horizontally and vertically centered, with left justification. You can change this by modifying the .horizontalAlignment, .verticalAlignment and .justification properties respectively. The text can also be modified after the label has been created by changing the, surprise, .text property of the label

The node returned by BitmapGlyphLabel is of type SKNode. To get the total size of the node without computing it through SpriteKit you can access the .totalSize property of the label

bitmapglyphlabel's People

Contributors

gabrielnica avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.