Corona SDK Mobile Game Development / Corona SDK. Руководство для начинающих.

→Local variables
A local variable is accessed from a local scope and usually called from a function or block
of code. When we create a block, we are creating a scope in which variables can live or a
list of statements, which are executed sequentially. When referencing a variable, Lua must
find the variable. Localizing variables helps speed up the look-up process and improves the
performance of your code. By using the local statement, it declares a local variable.
local i = 5 -- local variable
The following is how to declare a local variable in a block:
x = 10 -- global 'x' variable
local i = 1
0 Локальные переменные
→Global variables
A global variable can be accessed in every scope and can be modified from anywhere. The
term scope is used to describe the area in which a set of variables live. You don't have to
declare a global variable. It is created as soon as you assign a value to it.
myVariable = 10
print( myVariable ) -- prints the number 10
0 Глобальные переменные
Глобальные переменные доступны в любом контексте вашей программы и могут быть изменены хоть откуда.
Термин контекст используется для обозначения области в которой живет установленная переменная.
Вам не нужно объявлять глобальные переменные. Они создаются когда вы присваиваете им значение.
myVariable = 10
print( myVariable ) -- prints the number 10
→For more information on Lua, refer to http://www.lua.org.
Valuable variables
Like in many scripting languages, Lua has variables. You can think of it as something
that stores values. When you apply a value to a variable, you can refer to it using the
same variable.
An application consists of statements and variables. Statements provide instructions on
what operations and computations need to be done. Variables store the values of these
computations. Setting a value into a variable is called an assignment.
Lua uses three kinds of variables: global, local, and table fields.
0 Подробнее о Lua вы можете узнать на сайте lua.org.
Переменные
Как и во многих языках программирования в Lua есть переменные. Вы можете думать о них как о том, что сохраняет значение. Приложение состоит из операторов и переменных. Операторы представляют собой инструкции о том, какие вычисления небходимо произвести. Переменные хранят значения этих вычислений. Назначение переменной какого-либо значения называестся присваиванием. Луа использует три типа переменных: глобальные, локальные и поля таблиц (бред какой-то)
→Lua has been useful in creating various applications and games. Many game programmers
have found Lua to be a convenient scripting language due to how easy it is to embed, its fast
execution, and its small learning curve. It is ubiquitous in World of Warcraft. It is also used by
Electronic Arts, Rovio, ngmoco, and Tapulous in games such as Angry Birds, Tap Tap Revenge,
Diner Dash, and so on.
0 Lua может быть очень полезен при создании приложений и игр. Многие игровые программисты находят Lua удобным скриптовым языком программирования, который легко встраивается и не требует длительного изучения. Он широко используется в игре WorldOfWarkraft. Он так же используется такими студиями, как Electronic Arts, Rovio, ngmoco и Tapulous.
→In this chapter, you will learn how to:
‹‹ Apply variables to a script
‹‹ Use data structures to form tables
‹‹ Work with display objects
‹‹ Implement functions using object methods and arguments
‹‹ Optimize your workflow
So let's get right to it.
Lua to the rescue
Lua is the industry standard for game programming. It is similar to JavaScript and Flash's
ActionScript. Anyone who's done any scripting in these languages will make the transition
to Lua almost immediately.
0 В этой главе вы научитесь:
Применять переменные в скрипте. Использовать структуры данных для создания таблиц. Работать с объектами отображения. Применять функции используя методы объектов и аргументы.
Lua - стандарт программирования игр. Он близок к JavaScript и ActionScript. Любой, кто программировал на этих языках с легкостью перейдет на Lua.
→Lua is the programming language used to develop the Corona SDK. Up until
now, we have learned how to use the major resources to run the SDK and other
development tools to create an application for mobile devices. Now that we
have dabbled into creating a couple of lines of code that make a program work,
let's jump into the fundamentals that will give you a better understanding of
what Lua is capable of.
0 Lua это язык программирования использующийся для разработки в Corona SDK. До этого момента мы научились использовать основные ресурсы для запуска SDK и другие инструменты разработки для создания приложений. Теперь мы попробуем создать пару строк кода.
Познакомимся с основой для лучшего понимания возможностей Lua.
→‹‹ Whether you're working on iOS (if you're a registered Apple Developer) or Android,
try installing any of the sample code to your device to see how the applications
work outside the simulator environment
‹‹ Take a look at the Ansca forums at http://developer.anscamobile.com/
forum/ and browse through the latest discussions on Corona development by
fellow Corona SDK developers and personnel
Now that you understand the process of displaying objects in Corona, we'll be able to dive
into other functions that will help create an operational mobile game.
In the next chapter, we'll be going into more depth on Lua programming language and
learning simple coding techniques that are similar to the sample code in Corona. You will
get a better understanding of the Lua syntax and notice how fast and easy it is to learn
compared to other programming languages. So let's get started!
0 ы
→Summary
In this chapter, we covered some of the necessary tools needed to start developing
applications for Corona SDK. Whether you are working on a Mac OS X or Microsoft
Windows, you will notice the similarities on how to work on both operating systems
and how simple it is to run Corona SDK.
To familiarize yourself with Corona better, try doing the following:
‹‹ Take the time to look into the sample code provided by Corona to view
the capabilities of the SDK
‹‹ Feel free to alter any of the sample code to your liking to get a better
understanding of programming in Lua
0 Резюме.
В этой главе мы познакомились с небходимыми инструментами для разработки приложений в Corona SDK. Не зависимо от того, работаем мы на MacOS или Windows, разрабатывать и приложения
→Pop quiz – understanding Corona
1. When using Corona, which of the following statements is true?
a. You need a main.lua file to launch your application.
b. Corona SDK only runs on Mac OSX.
c. The Corona Terminal doesn't launch the simulator.
d. None of the above.
2. How many iOS devices can you use for development in the iPhone
Developer Program?
a. 50.
b. 75.
c. 5.
d. 100.
3. What does the Version Code have to be when building for Android
in Corona SDK?
a. A string.
b. An integer.
c. Has to follow the Java scheme format.
d. None of the above.
0 Викторина - понимание Corona
1. Когда мы используем Corona, какие из следующих утверждений верны?
а. Вам необходим файл main.lua для запуска вашего приложения.
б. Corona SDK запускается только под MacOS X
в. Corona Terminal не запускает симулятор
г. Ничего из вышеперечисленного.
2. Как много iOS устройств вы можете использовать для разработки согласно iPhone Developer Program?
а. 50
б. 75
в. 5
г. 100
3. Какое значение должно содержать поле Version Code в настройках создания сборки приложения под Android?
а. Строка
б. Целое число
в. В формате Java
г. Ничего из вышеперечисленного
→The Dropbox method is the most convenient method of... once you have it set up on your
computer and your mobile devices. All you have to do is drag-and-drop your .apk file to your
account folder and it's instantly accessible to any device with the Dropbox app installed. You
can also share your files through a download link—another great feature provided by Dropbox.
Setting up a Gmail account and sending your .apk files as attachments to yourself is a simple
process if you don't want to download any file managers and other programs to your device
and computer. The only thing you have to remember is that you can't e-mail an attachment
over the size of 25 MB in Gmail.
0 Загружать через Dropbox - самое удобное. Если он у вас конечно есть.

Если же вы не хотите заводить себе Dropbox и скачивать всякие там файловые менеджеры, можете просто послать сами себе приложение по почте, а на устройстве запустить его. Правда необходимо помнить, что к письму в Gmail можно прикрепить файл не больше 25 мегабайт.
→Using the file manager method allows you to access your .apk files easily without requiring
any carrier data or Wi-Fi connection. By using a USB cable that is compatible with your
device and connecting it to your computer, it's a simple drag-and-drop procedure.
0 Использование подключения по USB и файловый менеджер на устройстве - самый надежный способ. Вам даже не нужен интернет, чтобы загрузить приложение с вашего компьютера.
→What just happened?
We just learned several ways on how to load a .apk file to an Android device. The preceding
methods are some of the easiest ways to load an application quickly without running into
any problems.
0 Что произошло?
Мы научились нескольким способам загрузки приложения на Android-устройство. Представленные методы - самый простой и быстрый путь загрузить приложение.
→10. On your Android device, make sure you have your e-mail account linked on there
as well. As soon as you receive the message, open the e-mail, and you will be given
the option to install the application to your device. There will be an Install button
or something similar displayed.
0 10. Зайдите в свою почту на устройстве и вы сможете запустить прикрепленный к письму файл HelloWorld.apk.
→9. Address the recipient of the message to your own e-mail address and send it.
0 9. Отправьте это письмо сами себе. Т.е. в поле адресата укажите свой же email.
→8. Log in to your account, compose a new e-mail and attach your Hello World.apk
file to the message.
0 8. Создайте новое письмо в вашем почтовом ящике Gmail и прикрепите к нему HelloWorld.apk
→7. Once it has finished uploading, go to the Dropbox app on your device and select
your Hello World.apk file. You will be greeted with a screen that will ask you if
you want to install the application. Select the Install button. Assuming that it installs
correctly, another screen will appear saying Application installed and you can
launch your Hello World app by pressing the Open button that is available.
One of the easiest methods is through Gmail. If you don't already have a Gmail
account, create one at: https://mail.google.com/.
0 7. Запустите Dropbox на вашем устройстве и войдите в свой аккаунт. Выберите файл HelloWorld.apk. Вам будет показан экран подтверждения установки приложения. Выберите Install. Если установка прошла успешно, вам будет предложено запустить его нажав кнопку Open.

Еще один постой метод - через Gmail.
→6. Log in to your Dropbox account on your computer and mobile device. From
your computer, upload your Hello World.apk file.
0 6. Войдите в аккаунт Dropbox на компьютере и загрузите файл HelloWorld.apk
→5. Download the Dropbox installer and install it on your computer. Also,
download the mobile app from the Google Play Store (which is also free)
on to your device and install it.
0 5. Загрузите инсталлятор Dropbox и установите на своем компьютере Dropbox. Так же скачайте и установите Dropbox на вашем устройстве.
→4. Eject the drive from your desktop and disconnect your device from the USB
cable. Launch ASTRO File Manager or AppInstaller, whichever app you decided to
download from the Google Play Store. In ASTRO, select File Manager, search for the
folder you added on your SD card and select it. In AppInstaller, search for your newly
named folder and select it. In both apps, you will see your Hello World.apk file.
Select the file and a prompt will appear asking you to install it. Select the Install
button and you should see your Hello World application appear in the Apps folder
of your device A convenient method is through Dropbox. You can create an account at:
https://www.dropbox.com/. Dropbox is a free service that lets you
upload/download your files on your PC/Mac and mobile devices.
0 4. Отсоединитесь от компьютера. Запустите ASTRO File Manager или AppInstaller на вашем устройстве. Найдите вашу загруженную папку с приложением. Зайдите в папку и запустите файл HelloWorld.apk. Вы получите предупреждение об установке приложения. Нажмите Install и вы установите приложение. После этого оно должно появиться в папке Apps вашего устройства.

Так же удобно устанавливать приложения через Dropbox. Для этого вам необходимо завести аккаунт на Dropbox
→3. Connect the device to your computer with a USB cable. You will see a new
notification that a new drive has connected to your PC or Mac. Access the SD drive
and create a new folder. Name the folder something that you can identify easily for
your Android builds. Drag-and-drop your Hello World.apk file from the desktop
to the folder.
0 3. Присоедините ваше устройство к компьютеру по USB. На компьютере вы получите сообщение о подключении карты памяти. Зайдите на нее и создайте папку. Имя папки может быть любым, главное чтобы потом на устройстве ее было просто найти. Скопируйте в эту папку ваше приложение HelloWorld.apk.
Резюме
Пол:
мужчина
Родной язык:
русский
С нами:
с 26 сентября 2013 г. (4768 дней) по приглашению notabenoid
Деятельность:
2426 версий перевода с общим рейтингом 13
1 комментарий
Карма: 1 (оценок: 1)
Написать bubenok личное сообщение