[RPGXP]0----Hướng Dẫn Script Cho RPG Maker XP----0

  • Thread starter Thread starter ken10
  • Ngày gửi Ngày gửi
A thế là có tri kỉ rồi .Mình hiện đang nghiên cứu làm sao để nó có thể làm như Audition và trong lúc bí quá mình cũng nghĩ nó đơn giản chỉ là 1 vạch chạy qua như trong FF X .Đúng là ở đây bạn bè thì một đống mà tri kỉ lại chỉ có 1 .Khó hiểu quá ::(



Cái này đơn giản mà .Thứ nhất cái
Mã:
self.contents = Bitmap.new(width-32, height-32)
Thứ nhất vì sao nó lại có width-32 và height-32.Vì thật ra ban đầu cái Bitmap (Nôm na là hình ảnh) nó bao gồm cả cái đường viền màu trắng và thêm 1 khoản trắng mà bạn không thấy vì nó trùng với cái màu Windowskin .Do đó ta dùng Width(Chiều rộng) - 32 và Height(Chiều cao) để nó có thể ăn khớp với màn hình .Nếu muốn thì không để cái ấy cũng được nhưng nó sẽ không đẹp .

thứ nhất cái Method draw_text nó có tính chất như sau :
Mã:
...draw_text(x,y,width,height,@text) 
#x tọa độ x(Trục hoành)
#y  tọa độ y(Trục tung)
#width (Chiều rộng của đoạn text truờng là klớn hơn độ dài thật của text)
#height (Chiều cao nó cũng tương tự như trên)

Cái này liên quan đến SubClass và SuperClass
Như bên trên ta thấy My_Window < Window_Base
có nghĩa là My_Window có tất cả các Method và Variable trong Window_Base .Nhưng nếu để như thế thì nó không thể phân biệt được Window_Base vì nó giống nhau quá ,hóa ra đó là Bố Con Song Sinh à (Tui đùa đó :D)Cái "self.contents" nó có tác dụng làm cho cái My_Class có tính chất riêng của chính nó .Tức là nó sẽ sửa lại tính chất của Window_Base sau khi qua lệnh "self.contents" .BNó có tác dụng thay đổi các đặc tính của Window_Base và thay vào đó là đặc tính riêng của nó mà Window_base không có .Cứ vui vẻ với những bài dạy của Dubealex đi .Mấy cái bài đó hay lắm ,nhưng có điều nó quá ngắn chưa đủ để tiến xa hơn bằng mấy ổng được T_T


_Vậy bác định làm cái vạch chạy đó bằng script nào vậy chỉ cho cháu với mà nhớ cho cháu biết cách chép vào nữa nhé.
_Nhưng làm như vậy xong mình muốn các trận đánh thể hiện theo kiểu tủn như trong FF thì sao ạ nó cứ loại battle (đánh theo lược hoài à).Với lại như vậy thì chỉnh thời gian cho 1 lược khớp với ống thời gian thì như thế nào ạ.
 
Mã:
#===================================================
# ■ Text Scroll Script  R3-Fixed - Created by dubealex
#===================================================
# For more infos and update, visit:
# rmxp.dubealex.com
#
#-> Stack level too deep caused by ALIAS now fixed.
#
# November 29, 2004
#===================================================

#===================================================
# ▼ CLASS Text_Scroller Begins
#===================================================
class Text_Scroller

def initialize (file, opacity_scroll, opacity_bg, speed, live_scroll)
   
   text=IO.readlines("Text/#{file}")
   $tss_speed = speed
   $tss_iteration = 480.0/speed
   $tss_sy= (text.size*32) + 64
   
   $tss_scroll_window = Window_Scroll.new(file, 640, $tss_sy)
   $tss_scroll_window.opacity = opacity_scroll
   $tss_scroll_window.z=500
   $tss_scroll_window.x = 0
   $tss_scroll_window.y = 480
   
   $tss_bg_window = Window_bg.new
   $tss_bg_window.opacity = opacity_bg
   $tss_bg_window.z=400
   
   case live_scroll
   when 0  
     update
     when 1  
       $live_scroll=true
   end
end  

def update
       for i in 0...(($tss_sy/480.0) * $tss_iteration) + $tss_iteration
          $tss_scroll_window.y -= $tss_speed
          Graphics.update
        end
        $tss_scroll_window.dispose
        $tss_bg_window.dispose
  end
end
#===================================================
# ▲ CLASS Text_Scroller Ends
#===================================================


#===================================================
# ▼ CLASS Window_Scroll Begins
#===================================================
class Window_Scroll < Window_Base

def initialize (file, sx, sy)
   @sx=sx
   @sy=sy
   
   super(0, 0, sx, sy)
   self.contents = Bitmap.new(width - 32, height - 32)
   self.contents.font.name = "Tahoma"
   self.contents.font.size = 24
   @text=IO.readlines("Text/#{file}")
   @text_color=0
   refresh
end

def refresh    
   y=0
     for i in [email protected]
       y+=32
       if @text[i].index('/') == 0
           @text_color=@text[i].slice! (0..2)
           @text_color.slice!(0)
       end  
       if @text[i].index('*') == 0
           line_color=@text[i].slice! (0..2)
           line_color.slice!(0)
          self.contents.font.color = text_color(line_color.to_i)
        else
       self.contents.font.color = text_color(@text_color.to_i)
       end
       self.contents.draw_text(0, y, @sx, 32, @text[i])
     end
end
end
#===================================================
# ▲ CLASS Window_Scroll Ends
#===================================================


#===================================================
# ▼ CLASS Book_Scroll Begins
#===================================================
class Book_Scroll

def initialize (book_name, number_of_pages, start_page, opacity_scroll, opacity_bg)
   
   file = book_name.to_s+"/"+start_page.to_s+".rxdata"
   text=IO.readlines("Text/#{file}")
   $tss_sy= (text.size*32) + 64
   
   $tss_scroll_window = Window_Scroll.new(file, 640, $tss_sy)
   $tss_scroll_window.opacity = opacity_scroll
   $tss_scroll_window.z=500
   $tss_scroll_window.x = 0
   $tss_scroll_window.y = 0
   
   $tss_bg_window = Window_bg.new
   $tss_bg_window.opacity = opacity_bg
   $tss_bg_window.z=400
   
   book_update(book_name, start_page, number_of_pages, opacity_scroll, opacity_bg)
   $game_system.menu_disabled = true
end  

def book_update(book_name,start_page, number_of_pages, opacity_scroll, opacity_bg)
   loop do
   Graphics.update
   Input.update
   if Input.repeat?(Input::RIGHT) and number_of_pages > 1
     unless start_page == number_of_pages
       start_page+=1
     else
       start_page=1
     end  
     $tss_scroll_window.dispose
     $tss_bg_window.dispose
     Book_Scroll.new(book_name, number_of_pages,start_page, opacity_scroll, opacity_bg)
     break
   end
   if Input.repeat?(Input::LEFT) and  number_of_pages > 1
     unless start_page == 1
       start_page-=1
     else
       start_page=number_of_pages
     end  
     $tss_scroll_window.dispose
     $tss_bg_window.dispose
     Book_Scroll.new(book_name, number_of_pages,start_page, opacity_scroll, opacity_bg)
     break
   end
   if Input.repeat?(Input::UP)
     $tss_scroll_window.y+=15
   end  
   if Input.repeat?(Input::DOWN)
     $tss_scroll_window.y-=15
   end  
   if Input.trigger?(Input::B)
     $tss_scroll_window.dispose
     $tss_bg_window.dispose
     $game_system.menu_disabled = false
     break
   end
end
end  
   
end
#===================================================
# ▲ CLASS Book_Scroll Ends
#===================================================


#===================================================
# ▼ CLASS Scene_Map Additional Code Begins
#===================================================
class Scene_Map

alias alex_tss_original_update update
@@i=0

def update
alex_tss_original_update
   
   if $live_scroll==true
      $tss_scroll_window.y -= $tss_speed
       @@i+=1
       if @@i ==(($tss_sy/480.0) * $tss_iteration) + $tss_iteration
         $tss_scroll_window.dispose
         $tss_bg_window.dispose
         @@i=0
         $live_scroll=false
       end  
   end
end
end
#===================================================
# ▲ CLASS Scene_Map Additional Code Ends
#===================================================


#===================================================
# ▼ CLASS Window_bg Begins
#===================================================
class Window_bg < Window_Base

def initialize
   super(0, 0, 640, 480)
end
end
#===================================================
# ▲ CLASS Window_bg Ends
#===================================================

Đây là Script của nó , cách sử dụng :

1. Tạo 1 thư mục trong Game, đặt tên là Text
2. Soạn thảo 1 văn bản mà mình muốn , để vào trong thư mục Text đó
3. Gọi Script : Text_Scroller.new("tên file văn bản.txt", 0, 0, 1, 0)
Trong đó số 1 là tốc độ nhanh chậm của cuộn

.
 
Bác ken ơi,bác cho tôi cái Script menu chiến đấu của FF đi,cái giống the sin đó,thấy nó hay quá mà không biết cách làm.


Có phải cái như thế này ko?

ffxt1.JPG


ffxt3.JPG


Cái đó do Tính Edit lại, đây làn nguyên bản:

ffx1.JPG


Còn cái này là của bác Dương:

duong1.JPG


Vào đây Down Demo về nè: http://www.bolobala.net/diendan/showthread.php?t=173
 
Back
Top