Howdy, Stranger!

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

about making a letter sprite

edited December 2014 in Questions Posts: 289

i wanna try to making a letter's codea sprite on win7, its good on win7, but its not good on ipad, and i dont know how to upload it so that everyone could check it out to make some suggestions.
there is a download : http://pan.baidu.com/s/1mgC7EoK

Tagged:

Comments

  • Posts: 688

    What you need to do is create an image and then call setContext() to render to that image and then draw the letter multiple times.

    So in your example you'd set the color to grey and then draw the letter a few times, offseting the x & y values a little to create the dropshadow. Then set the color to red and draw it again in the original place to create the stroke effect and then lastly set the color to white and reduce the size slightly to create the inner color.

    You will probably want to set the textMode() to CENTRE to make lining up the images easier.

    I used a similar method to draw my gradient text.

    What I'd do is wrap all of the above into a function that you can call for each letter.

    Hope this helps

    Jon...

  • Posts: 289

    @TechDojo - thanks, at first i tried your method and use italic font, i couldnt accomplish it, so i wanna use sprite and regular font.

  • Posts: 688

    Your method should work with any font.

  • edited December 2014 Posts: 289

    @TechDojo - please tell the values for best elegance on hd ipad: if FontSize = 256, RimThickness = ,ShadowOffset = , and other vars.

  • dave1707dave1707 Mod
    Posts: 7,836

    @firewolf I'm not sure what you're after, but is it like this. I tried your link above, but I didn't see anything.


    function setup() fontSize(256) imgA=image(256,256) setContext(imgA) letter("A",128,128) setContext() imgB=image(256,256) setContext(imgB) letter("B",128,128) setContext() end function draw() background(40,40,50) sprite(imgA,200,200) sprite(imgB,200,500) end function letter(v,x,y) fill(255,255,255,100) for z=1,10 do text(v,x+z,y+z) end fill(255,0,0) text(v,x,y) end
  • Posts: 688

    @firewolf - sorry, that really depends on what effect your trying to achieve.
    What I'd suggest is creating a test program where each of those are set via parameters and then when you've found ones that look nice then you'll be able to copy down the values to use in your main project.

  • Posts: 289

    @dave1707 thanks, if i wanna add win7's font into codea, does it work? like adding sprite into codea?

  • Posts: 289

    @TechDojo thanks, if i wanna add win7's font into codea, does it work? like adding sprite into codea?

  • Posts: 127

    hi @firewolf, don't know if this what you're after and if suits @techdojo suggestions, but I usually add up custom fonts to codea with a third party app named AnyFont, you can grab it for 2 or 3 Euro on the appstore. It will allow you to install additional fonts straight away to your ipad without any mac/win sync. Mind that after installing a new font, you won't be seeing it in the ipad font list, but it will be working either way if you type in the correct naming in the font() function. such as font("bitdust")

    hope this helps

  • Posts: 289

    @deactive thanks, if i wanna add win7's font to codea like adding sprite to codea, is it possible?

  • edited December 2014 Posts: 688

    @deactive - DUDE! you're a star, I've been looking for a way to add custom fonts to Codea for ages. Do you know if they appear ok when you do an xCode export or do you need to add them to the project yourself.

    I'm surprised that Apple let this one through but I'm definitely getting this whilst I can!

    As for compatibility - There is some code floating around that just calls font() with a text string like you suggest and through a bit of trial and error I discovered a few extra fonts that work like "Chalkduster" that I think is installed with Keynote.

    UPDATE.

    I've brought Any Font and installed my custom font (.otf format) as per the tutorial.
    I restarted Codea and the font is available if I access it via it's name - instead of using the font picker.

    I exported the app as an xCode project - the custom font is NOT included (not really surprised).

    I opened the project in xCode and added the font as a resource in the Resource folder (in the same place as the default Codea ones.

    Ran the project and my font wasn't recognised :(

    After five minutes of tinkering I edited the -info.plist file and in the section "Fonts provided by application" I added an extra entry with the font file name and tried again.

    BINGO!

    Custom font's IN Codea - and in my exported xCode project!!!! #Result!

    (yes this is a big deal for me - it was the only bone of contention with the designer!)

    So @deactive - that's one massive beer I owe you!

  • Posts: 127

    Hi @techdojo, i love beer, thanks! I never tried to check what additional fonts are treated within xcode so far. But i've noted down the info.plist trick for future occurrences. Sooo, thank you too! :D

Sign In or Register to comment.