Per 2016, RMID pindah ke RMID Discord (Invite link dihapus untuk mencegah spambot -Theo @ 2019). Posting sudah tidak bisa dilakukan lagi.
Mohon maaf atas ketidaknyamanannya dan mohon kerjasamanya.

Share | 
 

 Spritefont Text Generator (WIP)

Topik sebelumnya Topik selanjutnya Go down 
Spritefont Text Generator (WIP) Empty2011-04-05, 14:11
PostSpritefont Text Generator (WIP)
#1
bungatepijalan 
Moe Princess
bungatepijalan

Level 5
Posts : 1487
Thanked : 30
Engine : Multi-Engine User
Skill : Intermediate
Type : Developer
Awards:
Spritefont Text Generator (WIP) Vide
Spritefont Text Generator
Versi: 1.0 (WIP)
Tipe: Custom Text Drawing System


Pengenalan

Script ini digunakan untuk menampilkan teks dengan menggunakan sprite yg disebut Spritefont, tidak dengan font2 yg terinstal di komputer. Sistem ini banyak digunakan di beberapa game konsol (Sega, PS, DOS games, dll) dan bahkan game2 kecilan yg sekarang juga menggunakan ini.
Dengan sistem ini, anda dapat membuat dan menggunakan style tulisan sendiri tanpa harus membuat file font dan menginstalnya di komputer, hanya dengan mengedit spritefont di image editor anda (Paint, Photoshop, etc).
Berikut ini contoh spritefont:
Spritefont Text Generator (WIP) Sprite10



Features To-Do List

  • Text alignment (left, center, right) [DONE]
  • Multiline text [N/A]
  • Word wrap text [N/A]
  • Characters with non-uniform widths. [N/A]
  • Meng-override bagian2 script default RGSS yang menampilkan teks2 di menu dan dialog dengan sistem spritefont [N/A]



FAQ

Q: Apa itu spritefont?
A: Sprite yang berisi tile2 karakter teks, seperti yg ditunjukkan di contoh di atas.

Q: Gimana cara masang scriptnya?
A: Tinggal lgs copas di slot script yg baru.

Q: Gimana cara menggunakannya?
A: Lihat petunjuk di script-nya dan pelajari demo-nya.

Q: Saat pindah scene, koq teksnya tetep ada?
A: Berarti anda lupa panggil method dispose setelah Graphics.freeze ato bagian dispose scene-nya

Q: Kenapa script ini masih WIP?
A: Belum semua fitur di To-do List diimplementasikan disini.

Q: Koq huruf2 yg ditampilkan ga sesuai?
A: Berarti penyusunan karakter2 di spritefont anda ada yg salah. Susunannya harus sesuai urutan kode ASCII, mulai dari kode 33 ('!') sampai 176. Atau biar ga bingung, lihat di contoh spritefont.

Q: Ukuran gambar spritefont bebas ga?
A: Ya, tapi panjangnya hrs kelipatan 16 dan lebarnya hrs kelipatan 9.

Q: Bisakah script ini digunakan di RMVX?
A: Ya, karena scriptnya tidak memanipulasi script2 default. Tapi penggunaannya mungkin sedikit berbeda.



Screenshot

Spritefont Text Generator (WIP) _unitl13


Demo

Sample untuk menampilkan teks2 di scene baru (pake RMXP). Disini navigasi New Game tidak ke Scene_Map, tapi justru ke scene baru tsb.
http://ifile.it/98voxpq/spritefont.zip


Script

Code:
#==============================================================================
# Spritefont Text Generator (WIP)
# Version 1.01
#==============================================================================
# Copyrighted by Bunga Tepi Jalan.
#  * Don't forget to credit me if you want to use this work
#  * You are free to Share - to copy, distribute and transmit the work
#  * You are free to Remix - to adapt the work
#  * You may not use this work for commercial purposes
#
#==============================================================================
# Information:
#  This script enables you to draw text using a sprite, called spritefont,
#  without having to use fonts installed on your computer.
#
# Usage Notes
#  - Place spritefont files at location as configured in this script.
#  - Each spritefont file contains 16x9 character tiles, so its width and
#    height must be divisible by 16 and 9, respectively (e.g. 144x108).
#  - Character tiles are ordered by ASCII code of the characters,
#    beginning from code 33 to 176.
#  - Don't forget to call update method after changing the text position.
#  - Don't forget also to call dispose method in the end of current scene.
#
# If you find any bugs or you have any suggestions, please report them via
# e-mail (listra92@gmail.com), or either my blog or these forums:
#  - http://bungatepijalan.wordpress.com
#  - http://rmid.forumotion.net
#==============================================================================

module Spritefonts
  #--------------------------------------------------------------------------
  # * Spritefont Text Generator Configuration
  #--------------------------------------------------------------------------
  # Location of spritefont files to be used
  SF_PATH = "Graphics/Pictures/spritefonts/"
 
  #==============================================================================
  # ** SFText
  #------------------------------------------------------------------------------
  #  An instance of this class represents a text drawn on the screen. Use
  #  Spritefonts::SFText.new(...) to create a new one.
  #==============================================================================
  class SFText
    #--------------------------------------------------------------------------
    # * Public Instance Variables
    #--------------------------------------------------------------------------
    attr_accessor :x
    attr_accessor :y
    attr_reader :text
    attr_reader :align
    #--------------------------------------------------------------------------
    # * Object Initialization
    #    sfname  : spritefont file name (without path)
    #    _text  : text string
    #    _x, _y  : position of text
    #    _align  : text alignment (0: left, 1: center, 2: right)
    #--------------------------------------------------------------------------
    def initialize(sfname, _text, _x = 0, _y = 0, _align = 0)
      @x = _x
      @y = _y
      @text = _text
      @align = _align
      @sfb = Bitmap.new(SF_PATH+sfname)
      @chars = Array.new
      update
    end
    #--------------------------------------------------------------------------
    # * Change Text
    #    _text  : new text string
    #--------------------------------------------------------------------------
    def change_text(_text)
      @text = _text
      update
    end
    #--------------------------------------------------------------------------
    # * Change Align
    #    _align  : text alignment (0: left, 1: center, 2: right)
    #--------------------------------------------------------------------------
    def change_align(_align)
      @align = _align
      update
    end
    #--------------------------------------------------------------------------
    # * Update Text Display
    #--------------------------------------------------------------------------
    def update
      cw = @sfb.rect.width/16
      ch = @sfb.rect.height/9
      if @chars.length != 0
        dispose
        @chars = Array.new
      end
      for i in 0..@text.length-1
        @chars.push(Sprite.new(Viewport.new(x+cw*i, y, cw, ch)))
        @chars[i].bitmap = @sfb
        @chars[i].x = -((@text[i]-1)%16)*cw
        @chars[i].y = -((@text[i]-1)/16-2)*ch
        if @align == 1
          @chars[i].viewport.rect.x -= cw*@text.length/2
        elsif @align == 2
          @chars[i].viewport.rect.x -= cw*@text.length
        end
      end
    end
    #--------------------------------------------------------------------------
    # * Dispose
    #--------------------------------------------------------------------------
    def dispose
      for i in 0..@chars.length-1
        @chars[i].dispose
      end
    end
  end
end


Credits

  • Bunga Tepi Jalan


Terakhir diubah oleh bungatepijalan tanggal 2011-04-05, 16:57, total 1 kali diubah (Reason for editing : Ralat script...)
Spritefont Text Generator (WIP) Empty2011-04-05, 14:49
PostRe: Spritefont Text Generator (WIP)
#2
DrDhoom 
Doomed Zombie
DrDhoom

Level 5
Posts : 629
Thanked : 22
Engine : Multi-Engine User
Skill : Intermediate
Type : Scripter

Spritefont Text Generator (WIP) Vide
wah mntp nih script ny... btw, character ny bs dtmbh lg g tuh...
Spritefont Text Generator (WIP) Empty2011-04-05, 15:00
PostRe: Spritefont Text Generator (WIP)
#3
Kuro Ethernite 
The Creator
Kuro Ethernite

Level 5
Posts : 1631
Thanked : 24
Engine : RMVX Ace
Skill : Masterful
Type : Jack of All Trades
Awards:

Spritefont Text Generator (WIP) Vide
errr..... jenis yg rada sama sperti yg prnah q request k seseorang :swt:
bisa buatin yg VX ga :( ?? and using iconset instead ?? :(

jdi ceritany brkesan sperti "show icon" d screen lngsung gtu XD
Spritefont Text Generator (WIP) Empty2011-04-05, 16:22
PostRe: Spritefont Text Generator (WIP)
#4
bungatepijalan 
Moe Princess
bungatepijalan

Level 5
Posts : 1487
Thanked : 30
Engine : Multi-Engine User
Skill : Intermediate
Type : Developer
Awards:
Spritefont Text Generator (WIP) Vide
@Dhoom
Char-nya cuma sebatas yg kode ASCII-nya 33 sampe 176. Kalo pengen nambah char2 yg unik, tinggal ganti aja di bagian char yg ga dipake (terutama di bawahnya char2 hurup kecil).

@Kuro
Ya seperti yg ditulis di FAQ:
Quote :
Q: Bisakah script ini digunakan di RMVX?
A: Ya, karena scriptnya tidak memanipulasi script2 default. Tapi penggunaannya mungkin sedikit berbeda.
Coba aja klo ga percaya :D
Spritefont Text Generator (WIP) Empty2011-04-05, 16:44
PostRe: Spritefont Text Generator (WIP)
#5
Kuro Ethernite 
The Creator
Kuro Ethernite

Level 5
Posts : 1631
Thanked : 24
Engine : RMVX Ace
Skill : Masterful
Type : Jack of All Trades
Awards:

Spritefont Text Generator (WIP) Vide
FAQ ny ga d baca tdi :hammer: :hammer:
fine then ~
I'll test it ~ :thumbup: ~
Spritefont Text Generator (WIP) Empty2011-04-05, 17:03
PostRe: Spritefont Text Generator (WIP)
#6
bungatepijalan 
Moe Princess
bungatepijalan

Level 5
Posts : 1487
Thanked : 30
Engine : Multi-Engine User
Skill : Intermediate
Type : Developer
Awards:
Spritefont Text Generator (WIP) Vide
Sori, ada sedikit ralat di scriptnya: di bagian method initialize-nya, dirobah jadi @sfb = Bitmap.new(SF_PATH+sfname), jadi ga akan selalu menggunakan nama "spritefont.png". Berikut ini script hasil ralatnya.
Code:
#==============================================================================
# Spritefont Text Generator (WIP)
# Version 1.01
#==============================================================================
# Copyrighted by Bunga Tepi Jalan.
#  * Don't forget to credit me if you want to use this work
#  * You are free to Share - to copy, distribute and transmit the work
#  * You are free to Remix - to adapt the work
#  * You may not use this work for commercial purposes
#
#==============================================================================
# Information:
#  This script enables you to draw text using a sprite, called spritefont,
#  without having to use fonts installed on your computer.
#
# Usage Notes
#  - Place spritefont files at location as configured in this script.
#  - Each spritefont file contains 16x9 character tiles, so its width and
#    height must be divisible by 16 and 9, respectively (e.g. 144x108).
#  - Character tiles are ordered by ASCII code of the characters,
#    beginning from code 33 to 176.
#  - Don't forget to call update method after changing the text position.
#  - Don't forget also to call dispose method in the end of current scene.
#
# If you find any bugs or you have any suggestions, please report them via
# e-mail (listra92@gmail.com), or either my blog or these forums:
#  - http://bungatepijalan.wordpress.com
#  - http://rmid.forumotion.net
#==============================================================================

module Spritefonts
  #--------------------------------------------------------------------------
  # * Spritefont Text Generator Configuration
  #--------------------------------------------------------------------------
  # Location of spritefont files to be used
  SF_PATH = "Graphics/Pictures/spritefonts/"
 
  #==============================================================================
  # ** SFText
  #------------------------------------------------------------------------------
  #  An instance of this class represents a text drawn on the screen. Use
  #  Spritefonts::SFText.new(...) to create a new one.
  #==============================================================================
  class SFText
    #--------------------------------------------------------------------------
    # * Public Instance Variables
    #--------------------------------------------------------------------------
    attr_accessor :x
    attr_accessor :y
    attr_reader :text
    attr_reader :align
    #--------------------------------------------------------------------------
    # * Object Initialization
    #    sfname  : spritefont file name (without path)
    #    _text  : text string
    #    _x, _y  : position of text
    #    _align  : text alignment (0: left, 1: center, 2: right)
    #--------------------------------------------------------------------------
    def initialize(sfname, _text, _x = 0, _y = 0, _align = 0)
      @x = _x
      @y = _y
      @text = _text
      @align = _align
      @sfb = Bitmap.new(SF_PATH+sfname)
      @chars = Array.new
      update
    end
    #--------------------------------------------------------------------------
    # * Change Text
    #    _text  : new text string
    #--------------------------------------------------------------------------
    def change_text(_text)
      @text = _text
      update
    end
    #--------------------------------------------------------------------------
    # * Change Align
    #    _align  : text alignment (0: left, 1: center, 2: right)
    #--------------------------------------------------------------------------
    def change_align(_align)
      @align = _align
      update
    end
    #--------------------------------------------------------------------------
    # * Update Text Display
    #--------------------------------------------------------------------------
    def update
      cw = @sfb.rect.width/16
      ch = @sfb.rect.height/9
      if @chars.length != 0
        dispose
        @chars = Array.new
      end
      for i in 0..@text.length-1
        @chars.push(Sprite.new(Viewport.new(x+cw*i, y, cw, ch)))
        @chars[i].bitmap = @sfb
        @chars[i].x = -((@text[i]-1)%16)*cw
        @chars[i].y = -((@text[i]-1)/16-2)*ch
        if @align == 1
          @chars[i].viewport.rect.x -= cw*@text.length/2
        elsif @align == 2
          @chars[i].viewport.rect.x -= cw*@text.length
        end
      end
    end
    #--------------------------------------------------------------------------
    # * Dispose
    #--------------------------------------------------------------------------
    def dispose
      for i in 0..@chars.length-1
        @chars[i].dispose
      end
    end
  end
end
Tapi sori, demo tidak di-update utk ralat ini. Sebagai gantinya, tinggal copas script baru ini aja.
Kalo nemu kesalahan lainnya, silakan reply, tp jangan request fitur dulu, soalnya msh WIP.

Thanks
Spritefont Text Generator (WIP) Empty2011-04-05, 17:13
PostRe: Spritefont Text Generator (WIP)
#7
Kuro Ethernite 
The Creator
Kuro Ethernite

Level 5
Posts : 1631
Thanked : 24
Engine : RMVX Ace
Skill : Masterful
Type : Jack of All Trades
Awards:

Spritefont Text Generator (WIP) Vide
yg d ralat itu, cuma biar ga slalu pake nama "spritefont.png" doank kan ?? :o

then, q cuma prlu sdikit mggunakan ilmu scripting q (yg rendahan ini :hammer: ) mgkin bisa q manipulasi ssuai kbutuhan q ~ :thumbup: (chance to manipulate : < 10% :hammer: )
Spritefont Text Generator (WIP) Empty2011-04-05, 21:34
PostRe: Spritefont Text Generator (WIP)
#8
KID_VX 
Senior
Senior
KID_VX

Level 5
Posts : 959
Thanked : 24
Engine : Multi-Engine User
Skill : Very Beginner
Type : Developer

Spritefont Text Generator (WIP) Vide
wah mantap nih :)
sangat berguna untuk kedepannya :)

Enjoy 8)
Spritefont Text Generator (WIP) Empty
PostRe: Spritefont Text Generator (WIP)
#9
Sponsored content 




Spritefont Text Generator (WIP) Vide
 

Spritefont Text Generator (WIP)

Topik sebelumnya Topik selanjutnya Kembali Ke Atas 

Similar topics

+
Halaman 1 dari 1

Permissions in this forum:Anda tidak dapat menjawab topik
RPGMakerID :: Scripts & Event Systems :: RMXP Scripts-