Difference between revisions of "Getting Started (简体中文)"

(Making a Game)
(制作游戏)
Line 18: Line 18:
 
end
 
end
 
</source>
 
</source>
 +
 +
== Running Games ==
 +
 +
LÖVE can load a game in two ways:
 +
* From a folder.
 +
* From a .love file (a renamed .zip-file).
 +
 +
In both cases, there has to be a file called <code>main.lua</code> in the root path. This file will be loaded when LÖVE starts. If this file is missing, LÖVE will not recognize the folder or .love file as game, and it will complain about a wrongly packaged game. A frequently made mistake is zipping the folder rather than its contents. This stems from very old practice (because when you unzip a folder you don't want it to splash out all over your current directory), but for LÖVE doing that doesn't make sense: you need to zip the game folder's contents '''only''', to get a correct .love.
 +
 +
===Windows===
 +
 +
On Windows, the easiest way to run the game is to drag the folder onto love.exe, or a shortcut to love.exe. Remember to drag the folder containing <code>main.lua</code>, and not <code>main.lua</code> itself.
 +
There's also the [[Scite]] option.
 +
 +
You can also call it from command line:
 +
 +
For instance:
 +
<pre>
 +
love C:\games\mygame
 +
love C:\games\packagedgame.love
 +
</pre>
 +
 +
On Windows, there is a special option which will attach a console to the Window. This allows you to see standard output.
 +
 +
<code>
 +
love --console
 +
</code>
 +
 +
===Linux===
 +
 +
On Linux, you can use the command line:
 +
 +
<pre>
 +
love /home/path/to/game
 +
love /home/path/to/packagedgame.love
 +
</pre>
 +
 +
If you have installed the .deb, you can double click on .love files in your file manager as well.
 +
 +
===Mac OSX===
 +
 +
On Mac OSX, a folder or .love file can be dropped onto the Love.app application bundle. On the Mac OSX Terminal (commandline), you can use love like this (assuming it's installed to the Applications directory):
 +
 +
<code>open -a love mygame</code>
 +
 +
In some cases it may be faster to invoke the love binary inside the application bundle directly via the following:
 +
 +
<code>/Applications/love.app/Contents/MacOS/love mygame</code>
 +
 +
You can setup an alias in your Terminal session to call the binary when you use <code>love</code> by adding an alias to your ~/.bash_profile (<code>open -a TextEdit ~/.bash_profile</code>):
 +
 +
<pre>
 +
# alias to love
 +
alias love="/Applications/love.app/Contents/MacOS/love"
 +
</pre>
 +
 +
Now you can call love from the commandline like Linux and Windows:
 +
 +
<code>
 +
love /home/path/to/game
 +
</code>

Revision as of 22:30, 1 May 2011

获得 LÖVE

LÖVE 网站 下载最新版本的 LÖVE,然后安装到电脑中。 如果使用 Windows 平台并不是必须要安装 LÖVE 才可使用,也可以通用下载 LÖVE 压缩包,然后解压到硬盘中任意位置的方式来使用 LÖVE 。

使用如下命令可以查看已安装的 LÖVE 版本:

love --version

制作游戏

要制作一个最小的游戏, 先在硬盘中任意位置创建一个文件夹,然后打开你喜欢的代码编辑器。 Notepad ++ 是 Windows 平台上很好的选择,它已经内建 Lua 支持。 在刚才创建的文件夹中新建一个名为 main.lua 的文件。 将下面的代码输入或复制到 main.lua 中,保存文件。

function love.draw()
    love.graphics.print("Hello World", 400, 300)
end

Running Games

LÖVE can load a game in two ways:

  • From a folder.
  • From a .love file (a renamed .zip-file).

In both cases, there has to be a file called main.lua in the root path. This file will be loaded when LÖVE starts. If this file is missing, LÖVE will not recognize the folder or .love file as game, and it will complain about a wrongly packaged game. A frequently made mistake is zipping the folder rather than its contents. This stems from very old practice (because when you unzip a folder you don't want it to splash out all over your current directory), but for LÖVE doing that doesn't make sense: you need to zip the game folder's contents only, to get a correct .love.

Windows

On Windows, the easiest way to run the game is to drag the folder onto love.exe, or a shortcut to love.exe. Remember to drag the folder containing main.lua, and not main.lua itself. There's also the Scite option.

You can also call it from command line:

For instance:

love C:\games\mygame
love C:\games\packagedgame.love

On Windows, there is a special option which will attach a console to the Window. This allows you to see standard output.

love --console

Linux

On Linux, you can use the command line:

love /home/path/to/game
love /home/path/to/packagedgame.love

If you have installed the .deb, you can double click on .love files in your file manager as well.

Mac OSX

On Mac OSX, a folder or .love file can be dropped onto the Love.app application bundle. On the Mac OSX Terminal (commandline), you can use love like this (assuming it's installed to the Applications directory):

open -a love mygame

In some cases it may be faster to invoke the love binary inside the application bundle directly via the following:

/Applications/love.app/Contents/MacOS/love mygame

You can setup an alias in your Terminal session to call the binary when you use love by adding an alias to your ~/.bash_profile (open -a TextEdit ~/.bash_profile):

# alias to love
alias love="/Applications/love.app/Contents/MacOS/love"

Now you can call love from the commandline like Linux and Windows:

love /home/path/to/game