等幅フォントの実験
投稿者:
光楼(114)
投稿日:2015/06/14 15:22
- 開始スクリプト
def decEquallyText() #最初に宣言
setVariable("EquallyTextGroupId", createArray()) #テキストグループId管理
#[グループID][X]
# [Y]
setVariable("EquallyTextDates", createArray()) #テキストグループ設定
#[グループID][] = textID
setVariable("EquallyTextGroupDates", createArray()) #テキストグループ管理
#[textID][X]
# [Y]
# [W]
# [h]
# [Mozi]
setVariable("EquallyTextIdDates", createArray()) #テキストデータ管理
end
decEquallyText()
def ETtextprint(id,x,y,w,h,m) #id,X,Y位置 幅高さ 文字
txid = createText(x, y, w, h)
setText(txid,m)
if getArrayLength(getVariable("EquallyTextGroupDates")[id]) == 0
getVariable("EquallyTextGroupDates")[id] = createArray()
end
pushArray(getVariable("EquallyTextGroupDates")[id], txid)
getVariable("EquallyTextIdDates")[txid] = createArray()
getVariable("EquallyTextIdDates")[txid][0] = x
getVariable("EquallyTextIdDates")[txid][1] = y
getVariable("EquallyTextIdDates")[txid][2] = w
getVariable("EquallyTextIdDates")[txid][3] = h
getVariable("EquallyTextIdDates")[txid][4] = m
end
def createEquallyText(x,y) #テキストグループ生成
n = getArrayLength(getVariable("EquallyTextGroupId"))
getVariable("EquallyTextDates")[n] = createArray()
getVariable("EquallyTextDates")[n][0] = x
getVariable("EquallyTextDates")[n][1] = y
getVariable("EquallyTextGroupDates")[n] = createArray()
pushArray(getVariable("EquallyTextGroupId"), n)
return n
end
def setEquallyText(Id,m) #テキストグループ設定
Siz = getTextFontSize() + 5 #サイズ調整
m = toString(m)
s = splitString(m, "")
i = 0
L = getArrayLength(s)
while i < L
TIDL = getArrayLength(getVariable("EquallyTextGroupDates")[Id])
if TIDL == 0 #グループに中身がなければ
x = getVariable("EquallyTextDates")[Id][0]
y = getVariable("EquallyTextDates")[Id][1]
w = Siz
h = Siz
else #グループに追加
x = getVariable("EquallyTextIdDates")[getVariable("EquallyTextGroupDates")[Id][TIDL - 1]][0]
y = getVariable("EquallyTextIdDates")[getVariable("EquallyTextGroupDates")[Id][TIDL - 1]][1]
w = Siz
h = Siz
x = x + w
end
if s[i] == "\n"
x = getVariable("EquallyTextDates")[Id][0] - w
y = y + h
w = 1
s[i] = ""
end
ETtextprint(Id,x,y,w,h,s[i])
i = i + 1
end
end
def deleteEquallyText(Id) #等幅テキスト表示削除
l = getArrayLength(getVariable("EquallyTextGroupDates")[Id])
i = 0
while i < l
txid = getVariable("EquallyTextGroupDates")[Id][i]
deleteText(txid)
getVariable("EquallyTextIdDates")[txid] = createArray()
i = i + 1
end
getVariable("EquallyTextGroupDates")[Id] = createArray()
getVariable("EquallyTextDates")[Id] = createArray()
end
def deleteEquallyTextAll() #等幅テキスト表示全削除
l = getArrayLength(getVariable("EquallyTextGroupId"))
i = 0
while i < l
deleteEquallyText(getVariable("EquallyTextGroupId")[i])
i = i + 1
end
end
- 使い方
i = 0 id = createEquallyText(20,20) while i < 1000 setEquallyText(id, i) i = i + 1 waitTime(1) deleteEquallyText(id) end setTextFontSize(40) a = createArray() a[0] = "ぼ" a[1] = "く" a[2] = "ら" a[3] = "は" a[4] = "み" a[5] = "ん" a[6] = "な" a[7] = "\n" a[8] = "い" a[9] = "き" a[10] = "て" a[11] = "い" a[12] = "る" i = 0 id = createEquallyText(200,150) while i < 13 setEquallyText(id, a[i]) i = i + 1 waitTime(500) end deleteEquallyTextAll()
実際にゲームにコピペして動かして見て下さい。
元の文字のサイズが異なるので若干ずれているようにも見えますが……
コメントする
コメントするには、ログインする必要があります。
コメント一覧
コメントはありません。