トランジションでテキストフィールドの色を変えることはできますか? このような通常の遷移を試みましたが、うまくいきませんでした。
explainer = display.newText("my text", 100,100,"Hiragino Maru Gothic Pro",30)
transition.to(explainer, { time=100, color="rgba(255,0,0)" })
blink
これは、エフェクトを作成できるコードです。増分を変更する部分を削除すると、うまくいきます。
local min_r,min_g,min_b=100,100,255 -- Initial color
local max_r,max_g,max_b=255,255,255 -- End color
local color_steps=15 -- Adjust this to make it more fast/slow
local current_step=0
local increment=1
local step_r=(max_r-min_r)/color_steps
local step_g=(max_g-min_g)/color_steps
local step_b=(max_b-min_b)/color_steps
function blink()
if (rowPlayerName and rowPlayerName["text"] and rowScore and rowScore["text"]) then
rowPlayerName:setTextColor( min_r+current_step*step_r, min_g+current_step*step_g, min_b+current_step*step_b )
rowScore:setTextColor(min_r+current_step*step_r, min_g+current_step*step_g, min_b+current_step*step_b )
current_step=current_step+increment
if (current_step>=color_steps) then
current_step=color_steps-1
increment=-increment
elseif (current_step<0) then
current_step=0
increment=-increment
end
timer.performWithDelay(50, blink)
end
end
blink()
この場合、rowPlayerName
とは一緒に変更する必要rowScore
がある 2です。display.newText
これは本当に transition.to ではできません。enterFrame リスナーでそれを行い、各ステップで R、G、B の値をインクリメントする必要があります。
また、別のオブジェクトを別の色でその上に置き、そのアルファを 0 に設定することもできます。次に、transition.to メソッドを使用して、このオブジェクトのアルファ プロパティを 1 に変更します。