1

トランジションでテキストフィールドの色を変えることはできますか? このような通常の遷移を試みましたが、うまくいきませんでした。

explainer = display.newText("my text", 100,100,"Hiragino Maru Gothic Pro",30)
transition.to(explainer, { time=100, color="rgba(255,0,0)" })
4

3 に答える 3

1

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

于 2013-11-07T09:13:58.223 に答える
1

これは本当に transition.to ではできません。enterFrame リスナーでそれを行い、各ステップで R、G、B の値をインクリメントする必要があります。

于 2013-10-28T00:17:08.323 に答える
0

また、別のオブジェクトを別の色でその上に置き、そのアルファを 0 に設定することもできます。次に、transition.to メソッドを使用して、このオブジェクトのアルファ プロパティを 1 に変更します。

于 2014-04-17T10:42:53.717 に答える