入力した文字を画像の中にスクロールしたい
ごりら 2013/6/16(Sun) 01:52:03|NO.54931
ニコニコ動画みたいに、画面の中に、入力した文字を横にスクロールさせたいんですけど
どうすればいいですかね(´・ω・`)
サンプルソースお願いします
忠敬君 2013/6/16(Sun) 04:42:23|NO.54935
こんな感じですかね
x=500
y=10
c=400
v=100
repeat : await 10
cls
x-1
pos x,y
mes "ニコニコ^−^"
c-2
pos c,v
mes "動画"
loop
忠敬君 2013/6/16(Sun) 04:44:18|NO.54936
すみません
ちらつき防止を入れたものです><><
x=500
y=10
c=400
v=100
repeat : await 10
cls
x-1
pos x,y
mes "ニコニコ^−^"
c-2
pos c,v
mes "動画"
redraw 0
redraw 1
loop
ごりら 2013/6/16(Sun) 11:02:01|NO.54942
すいません
少し言い間違えました
画像をぱらパラマンガみたいにして動画っぽいのを作ったんですけど
コメントを流れさせることができませんでした
どうしたらいいですかね
ht. 2013/6/16(Sun) 12:00:38|NO.54943
どうできなかったのかを具体的に説明するとか試行錯誤の形跡が感じられる質問をした方がこの先に良い支持を得られると思いますよ。
#define COMMENT_PER 50 // 一度に表示可能な件数
sdim comment_text, 256, COMMENT_PER
dim comment_x, COMMENT_PER
dim comment_y, COMMENT_PER
dim comment_speed, COMMENT_PER
pos 400, ginfo_winy - 30 : button gosub "ランダム投稿", *random_comment
pos 5, ginfo_winy - 30 : button gosub "投稿", *add_comment
pos 80, ginfo_winy - 30 : text = "" : input text, 200
new_y = 0 // 次のコメントのy座標
repeat
color : boxf : color 255, 255, 255
repeat COMMENT_PER
if comment_text.cnt == "" : continue
pos comment_x.cnt, comment_y.cnt
mes comment_text.cnt
comment_x.cnt -= comment_speed.cnt
// 画面から流れて消えた
if (comment_x.cnt + ginfo_mesx) < 0 {
comment_text.cnt = "" ;リストを空き領域に
new_y = comment_y.cnt ;そのときの行を新しいY座標に
}
loop
wait 4
loop
*add_comment
empty_id = -1
repeat COMMENT_PER
// 空いてるリストを探す (空いてなければ古い方から)
if comment_text.cnt == "" {
empty_id = cnt
break
}
loop
if empty_id == -1 {
// 空いてなければ一番寿命の短い(xの値が小さい)リストを潰す
x = 0
empty_id = 0
repeat COMMENT_PER
if x > comment_x.cnt {
x = comment_x.cnt
empty_id = cnt
}
loop
}
comment_text.empty_id = text
comment_x.empty_id = ginfo_winx
comment_y.empty_id = new_y
comment_speed.empty_id = 2 + strlen(text) / 4 // 長いコメントほど高速に流す
new_y += 16 ;この部分はWinAPIとかで文字列描画領域の縦幅を取得したほうがいいかも
if (new_y + 16) > ginfo_sizey : new_y = 0 ;はみ出たらリセット
return
*random_comment
sdim text, 64
repeat rnd(32)
poke text, cnt, 'a' + rnd('z' - 'a')
loop
gosub *add_comment
return
kanahiron 2013/6/16(Sun) 13:04:35|NO.54944
作ってる間にht.さんに先越されましたがもったいないので投下
#module
#deffunc drawcomment_init array comment_ , int screenw_,int second_, int fps_
screenw = screenw_
second = second_
fps = fps_
sdim comment,64,length(comment_)
repeat length(comment_)
comment.cnt = comment_.cnt
loop
dim count,length(comment)
dim commentsizew,length(comment)
repeat length(comment)
mes comment.cnt
commentsizew.cnt = ginfo(14)
speed.cnt = (( 0.0 + screenw + commentsizew.cnt) / (second*fps))
loop
return
#deffunc drawcomment int p1, double p2, int p3
if cnt > ((p2*1000)/fps) {
pos limit( (screenw-( speed(p1) * count(p1) )) , ( commentsizew(p1) * -2 ) , screenw ), p3
mes comment.(p1)
count(p1)++
}
return
#deffunc hold60fps
a++
if a != 3{
await 17
} else {
a=0
await 16
}
return
#deffunc hold30fps
a++
if a != 3{
await 33
} else {
a=0
await 34
}
return
/*
各命令の説明
drawcomment_init array p1, int p2, int p3, int p4
drawcommentの初期化命令
p1 sdimで確保した流したいコメントの配列変数を入れる
p2 スクリーンの横幅
p3 コメントが流れる時間(秒)
p4 repeat-loop内のフレームレート(await 16なら60、await 33なら30。hold60fps、hold30fpsを使うと便利)
drawcomment int p1, double p2, int p3
実際に流れるコメントを書く命令
p1 sdimで確保した流したいコメントの配列変数の番号(0〜)
p2 repeat-loop内で何秒目に流れ始めるか
p3 コメントの高さ
hold30fps (hold60fps)
await 33(16)より正確に30(60)fpsを保つ命令
引数無し
*/
#global
上のモジュールを保存して#includeでお使いください(ファイル名はご自由に)
使い方例
上記モジュールをnicomment.asとして保存した例
#include "nicomment.as"
buffer 1,640,480
gradf 0,0,640,480,0,0xEE4444,0xEEEE44
screen 0,640,480
font msgothic,31,1
sdim comment,64,10
comment.0 = "こんにちは"
comment.1 = "キタ━━━━(゜∀゜)━━━━!!"
comment.2 = "orz"
comment.3 = "でうfh9えw7fげwfh9えwfげwrへhb"
buffer 2,1000,50
font msgothic,31,1
drawcomment_init comment, 640, 4, 30
gsel 0
repeat
redraw 0
pos 0,0
gcopy 1,0,0,640,480
drawcomment 0, 1.0, 50
drawcomment 1, 1.5, 90
drawcomment 2, 2.0, 120
drawcomment 3, 0.3, 120
redraw 1
hold30fps
loop
説明
sdimで配列変数を作り、流したいコメントを入れる(9〜13行目)
適当なbufferを作り(IDは何でもいい)、drawcomment_initを実行する(15、18行目)
スクリーンにfont命令を使う場合はbufferにも同じフォントを指定する(16行目)
drawcomment_initの説明はモジュールをご覧ください
repeat-loop内でdrawcommentを実行(27〜30行目)
drawcommentの説明はモジュールを(ry
------
とメインのソースに書くのはたったこれだけで、モジュールをincludeするだけの簡単仕様です!
わからないことがあったら言ってください
kanahiron 2013/6/16(Sun) 19:56:34|NO.54967
すみません 上記モジュールにミスが有りました
26行目、 if cnt > ((p2*1000)/fps) {
を if cnt > (p2*fps) {
に修正してください
ごりら 2013/6/16(Sun) 21:24:02|NO.54968
今日はあまり時間がないので、明日やってみます