game.loading do |loader|
loader.add :window, :system => "window"
loader.add :gui_item, :system => "gui_item"
loader.add :back_image,91 #背景1
loader.add :btn_image,92 #背景2
loader.add :Character_image_1,93 #立ち絵1
#loader.add :Character_image_2, #立ち絵2
end
game.on_init do
set_window_image :window
set_gui_image :gui_item
scene_change :text_scene
end
LOCAL_DATA_CONSTANT = {}
def local_data
LOCAL_DATA_CONSTANT
end
scene :start_scene do |scene|#top
text = scene.text :position => [450, 20]
text.set_text_area_size 36, 440
text.set_font_point_size 35
text.set_text ("述べるんテスト開始! ")
text.event :on_click do |event|
scene_change :page_scene
end
text = scene.text :position => [250, 20]
text.set_text_area_size 36, 125
text.set_font_point_size 35
text.set_text ("終わる ")#最後にスペース入れないと『る』が見えない……。
text.event :on_click do |event|
game.change_project "start_menu"
end
end
scene :page_scene do |scene|#pageのシーン
l_image(scene, local_data[:n_p])#画像
l_text (local_data[:n_p])#text
###text表示
if local_data[:page_l]
text = scene.text :position => [65, 70], :layer_order => 8
text.set_text_area_size 680, 340
text.set_font_point_size 25
text.set_color 64, 64, 64, 255
text.set_text (local_data[:page_P][local_data[:n_p]])
else
#speak("t")
n = 0
while n < 17
nn = 700 - 40 * n
text = scene.text :position => [nn, 60], :layer_order => 8
text.set_text_area_size 26, 330
text.set_font_point_size 25
text.set_color 64, 64, 64, 255
text.set_text (local_data[:page_P][n])
n += 1
end
end
select_btn(scene)#btn
end
def select_btn(scene)#選択
text = scene.text :position => [295, 400], :layer_order => 10##junp
text.set_text_area_size 205, 50
text.set_font_point_size 35
text.set_color 224, 224, 224, 255
text.set_text (" select_page")
text.event :on_click do |event|
scene_change :pagej_scene
end
text = scene.text :position => [3, 7], :layer_order => 10##stratmenu
text.set_text_area_size 200, 50
text.set_font_point_size 35
text.set_color 224, 224, 224, 255
text.set_text (" startmanu")
text.event :on_click do |event|
scene_change :start_scene
end
text = scene.text :position => [610, 7], :layer_order => 10##page
text.set_text_area_size 300, 50
text.set_font_point_size 35
text.set_color 224, 224, 224, 255
text.set_text (" " + local_data[:n_p].to_s + " / " + local_data[:page_pmax].to_s)
text = scene.text :position => [5, 400], :layer_order => 10##next
text.set_text_area_size 210, 50
text.set_font_point_size 35
text.set_color 224, 224, 224, 255
if local_data[:page_l]
text.set_text (" ←back_page")
else
text.set_text (" ←next_page")
end
text.event :on_click do |event|
if local_data[:page_l]
local_data[:n_p] -= 1
else
local_data[:n_p] += 1
end
scene_change :page_scene
end
text = scene.text :position => [580, 400], :layer_order => 10##back
text.set_text_area_size 210, 50
text.set_font_point_size 35
text.set_color 224, 224, 224, 255
if local_data[:page_l]
text.set_text (" next_page→")
else
text.set_text (" back_page→")
end
text.event :on_click do |event|
if local_data[:page_l]
local_data[:n_p] += 1
else
local_data[:n_p] -= 1
end
scene_change :page_scene
end
end
def W_Text(a, z)###テキスト入力
#######文字列を行ごとに分ける。
#######スペースを任意数、改行をお尻に挿入。
#######ページ単位に合体!!
#######再び、スペースを任意数、改行をお尻に挿入。
#######
#a==0横書きa==1縦書き
if a == 0
#pageごとに配列化
local_data[:page_l] = true
e = z.split("☆")
local_data[:page_P] = []
local_data[:page_pmax] = 0
n = 0
e.each do |item|
local_data[:page_P][n] = "#{item}".sub("☆", " ")
n += 1
local_data[:page_pmax] += 1
end
local_data[:page_pmax] -= 1
elsif a == 1#####################
local_data[:page_l] = false
local_data[:page_A] = []
b = z.split("\n")
aaaaa = 0
n = 0
local_data[:page_B] = []
b.each do |item|
d = ((b[n].length) / 3).floor
if 17 == d#12
b[n] = "#{item}" + " \n"
else
c = 12 - d
while 0 < c
b[n] = b[n] + " "#挿入
c -= 1
end
b[n] = b[n] + " \n"#挿入
end
local_data[:page_A][n] = b[n]
n += 1
end
#pageごとに配列化
nn = 0
nnn = 0
pag = []
while n > 0
e = local_data[:page_A][nn].index("☆")
if e == nil
pag = pag + local_data[:page_A][nn]
else
pag = ""
f = local_data[:page_A][nn]
local_data[:page_A][nn] = f.sub("☆", " ")
pag = pag + local_data[:page_A][nn]
nnn += 1
end
local_data[:page_B][nnn] = pag
nn += 1
n -= 1
end
local_data[:page_pmax] = nnn#総ページ数
n = 2
nn = 1
g = 233#145
while nn <= local_data[:page_pmax]
h = ((local_data[:page_B][nn].length) / 3).floor
hh = h
gg = 0
while g >= h
if !(h == hh)
local_data[:page_B][nn] = local_data[:page_B][nn] + " "##
end
if gg == 12
local_data[:page_B][nn] = local_data[:page_B][nn] + "\n"
gg = 0
end
gg += 1
h += 1
end
nn += 1
end
end
end
def l_image(scene, a)##画像系
################image
#:back_image, #背景1
#:btn_image, #背景2
#:Character_image_1, #立ち絵1
#:Character_image_2, #立ち絵2
scene.add :image, :texture => :back_image, :align => :fullscreen, :layer_order => 0
scene.add :image, :texture => :btn_image, :align => :fullscreen, :layer_order => 9
sprite_template :hajime do |st|
st.texture:Character_image_1
#st.src_size 100, 100
#st.dest_size 32, 32
st.position -300, 0
st.motion :default do |commands|
end
st.motion :SLL do |commands|
commands.loop false
commands.move_to 100, 0, 15
commands.wait_motion
end
end
if a == 0
#if
#else
a = 1
#end
end
case a
when 2
c1 = scene.add :image, :template => :hajime
c1.change_motion :SLL
end
end
def l_text (a)#text系(page数)
################text
nn = local_data[:page_pmax] + 1
if local_data[:page_l]
if a >= nn#
speak("ページがありません。")
local_data[:n_p] = local_data[:page_pmax]
elsif a == 0
speak("ページがありません。")
local_data[:n_p] = 1
end
else
if a >= nn#
speak("ページがありません。")
local_data[:n_p] = local_data[:page_pmax]
local_data[:page_P] = local_data[:page_B][local_data[:page_pmax]].split("\n")
elsif a <= 0
speak("ページがありません。")
local_data[:n_p] = 1
a = 1
local_data[:page_P] = local_data[:page_B][a].split("\n")
else
local_data[:page_P] = local_data[:page_B][a].split("\n")
end
end
end
scene :pagej_scene do |scene|###pageジャンプ
scene.show_text_input :multiline_text, "半角数字でページを指定",
[127, 255, 127, 255],
"default", "ok", "cancel" do |e|
if e.submited
#speak e.content
n = (e.content).to_i
local_data[:n_p] = n.to_i
scene_change :page_scene
else
scene_change :page_scene
end
#bg_sprite.delete
end
end
scene :text_scene do |scene|#本文入力
########################縦書き(1ページは1行12文字、17行まで)
W_Text(1, z = <<E
☆文章表示文章表示文章表
示。
☆立ち絵を表示。
☆左上で最初の画面へ。
E
)
local_data[:n_p] = 1
scene_change :start_scene
end
##########################################################横書き(1ページは1行30文字、11行まで)
# W_Text(0, z = <<E
#☆あ
#いうえおかきくけこさしすせそたちつてとなにぬねのはひふへほ
#まみむめも
#う
#え
#お
#か
#き
#く
#け
#こ
#☆さ
#し
#す
#せ
#そ
#た
#ち
#E
#)
#local_data[:n_p] = 1
#scene_change :start_scene
#end
##########
##########