Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Color Emoji as sprites

edited January 2012 in Code Sharing Posts: 143

I've discovered that the new text rendering function introduced in v1.3 renders the colour emoji font. The font has a quite a few glyphs that would be useful for games. You can even type colour emoji into string literals in the Codea editor!

You need to acivate the emoji international keyboard in Settings > General > Keyboard.

Here's an helper function that turns some text into an image for use as a sprite or texture. I can't include an example of its use because the forum software barfs on the Unicode for the emoji glyphs.

function spriteFromFont(spriteFont, spriteFontSize, glyphs)

    fill(255, 255, 255, 255)

    local w, h = textSize(glyphs)
    local sprite = image(w, h)

    text(glyphs, 0, 0)


    return sprite


  • SimeonSimeon Admin Mod
    edited January 2012 Posts: 5,387

    It's a really cool side-effect of Apple's great font and type support. Very handy helper function, too!

    I believe you can just enable the Emoji keyboard in Settings -> Keyboards -> International Keyboards -> Add New Keyboard -> Emoji.

    (I updated your post to fix the code formatting)

  • NatNat
    Posts: 143

    You're right. The app I downloaded gave misleading instructions.

  • Cool function, Nat! Thanks for sharing

  • Posts: 2,820

    Just a heads up, I'm planning to make a class where you say eEmoji(character,x,y) which will throw the emoji character. Now that's easy to do, but the good thing about this is that it will automatically change it to emoji font and then change it back to the font you had. :-)

  • Posts: 2,820

    By the way, does mesh work with drawing text?

  • Posts: 2,820

    Ahh! I didn't see your code. There was an error loading the code :-(

  • Posts: 2,820

    I also like to use the chinease simplified handwriting keyboard to draw character. Just recolor them, and they're awsome. I also like Touch&Copy to get more character.

  • BortelsBortels Mod
    Posts: 1,557

    Mesh doesn't work with drawing text directly, but using setContext() you can easily make an image with your text, then use that as the texture for the mesh. I posted some sample code that does just that in another thread... somewhere...

Sign In or Register to comment.