cheka.jp 超不定期で更新する写真達。お口直しにどうぞ。

Corona SDKを触ってみた 1

Coronaはmain.luaを起動ファイルとして扱うようなので、main.luaを準備して色々試してみます。

まずは定番のHello Worldから。

textObject = display.newText("Hello World!",50,40,"Times New Roman",36);
textObject:setTextColor(124,252,0);

コードを書いたらCoronaSDKのSimulatorをクリックして保存したmain.luaを選択してみます。
1
記述ミスがなければ下記のように表示されていると思います。
2

次は画像表示を試してみます。
適当な背景をRetina用まで準備してimageフォルダ以下へ配置します。
bg.png(320×480)、bg@2x.png(640×960)、star.png(82×78)、star@2x.png(164×156)

local myImage = display.newImageRect( "./image/bg.png",320,480);
myImage.x = display.contentWidth / 2;
myImage.y = display.contentHeight / 2;
local star1 = display.newImageRect("./image/star.png",82,78);
star1.x = display.contentWidth / 2;
star1.y = 80;
local star2 = display.newImageRect("./image/star.png",82,78);
star2.x = display.contentWidth / 2;
star2.y = 200;
local star3 = display.newImageRect("./image/star.png",82,78);
star3.x = display.contentWidth / 2;
star3.y = 320;

コードを記述して保存します。
Simulatorは自動で反映されるようにしていた場合は保存するだけで画面に反映されます。
他の設定でも確認してみるとiPhoneでは期待通りに表示されると思いますが、Retina対応のiPhoneでは期待と異なる表示になってしまうので表示を調整してみましょう。
1

2

プロジェクトフォルダにconfig.luaを準備して設定を記述します。

application =
{
content =
{
width = 320,
height = 480,
scale = "letterbox",
imageSuffix =
{
["@2x"] = 2,
},
},
}

正しく表示されている事を確認。
スクリーンショット 2013-05-14 21.42.22

スクリーンショット 2013-05-14 21.42.29

Add a Comment

メールアドレスが公開されることはありません。