Difference between revisions of "love (简体中文)"

m
m (删除 “ Concept:Current”)
 
(10 intermediate revisions by 4 users not shown)
Line 1: Line 1:
The root module which contains all the other modules.
+
当你开始用 LÖVE 编写游戏时, 需要了解几个最重要的 API 回调函数:
Clearly the loveliest module of all.
+
[[love.load]] 仅执行一次,用于初始化加载你的游戏,
这些包含了全部爱的基本模块.他们实在是忒可爱了~
+
[[love.update]] 用于管理你的游戏每一帧的状态,
 +
[[love.draw]] 用于渲染你的游戏到屏幕。
  
 +
为了处理玩家输入的信息以及呈现一个全方面体验的游戏,很多交互将会重写额外的回调函数.
  
When beginning to write games using LÖVE|当你开始用LÖVE写游戏, the most important parts of the API are the callbacks: [[love.load]] to do one-time setup of your game|接口里面最重要的几个函数就属love.load来执行一次初始游戏设定, [[love.update]] which is used to manage your game's state frame-to-frame|函数love.update用来管理你游戏框架之间的状态, and [[love.draw]] which is used to render the game state onto the screen|以及love.draw函数把你的游戏整到屏幕上供你XX~.
+
LÖVE 提供了默认的空回调函数,你可以通过对应的回调函数名在你自己的代码里重写这些函数:
  
说白了就是你搞明白这3你就能开始闹腾了!
+
<source lang="lua">
 +
-- 初始化矩形的一些默认值
 +
function love.load()
 +
    x, y, w, h = 20, 20, 60, 20
 +
end
  
 +
-- 每一帧增加矩形的尺寸
 +
function love.update(dt)
 +
    w = w + 1
 +
    h = h + 1
 +
end
  
 +
-- 绘制有颜色的矩形
 +
function love.draw()
 +
    love.graphics.setColor(0, 100, 100)
 +
    love.graphics.rectangle("fill", x, y, w, h)
 +
end
 +
</source>
  
More interactive games will override additional callbacks in order to handle input from the user, and other aspects of a full-featured game.
 
  
为了处理玩家输入的信息以及呈现一个全方面体验的游戏,很多交互将会重写额外的回调函数.
+
'''注意:如果下面的列表为空或者缺少,说明还没有对应的中文翻译,欢迎贡献翻译。'''
  
  
 +
== 模块 ==
 +
{{#ask: [[Category:Modules]] [[parent::love (简体中文)]]
 +
| headers=hide
 +
| format=template
 +
| template=ListingFields
 +
| introtemplate=ListingIntro
 +
| outrotemplate=ListingOutro
 +
| ?Description
 +
| ?PrettySince
 +
| ?PrettyRemoved
 +
}}
  
LÖVE provides default placeholders for these callbacks, which you can override inside your own code, simply by specifying their fully qualified name:
+
== 第三方模块 ==
 +
{{#ask: [[Category:Libraries]] [[parent::love (简体中文)]] [[Concept:Current]]
 +
| headers=hide
 +
| format=template
 +
| template=ListingFields
 +
| introtemplate=ListingIntro
 +
| outrotemplate=ListingOutro
 +
| ?Description
 +
| ?PrettySince
 +
| ?PrettyRemoved
 +
}}
  
LÖVE提供默认的placeholders?占位符?←这句翻译不算
+
== 函数 ==
 +
{{#ask: [[Category:Functions]] [[parent::love (简体中文)]] [[Concept:Current]]
 +
| headers=hide
 +
| format=template
 +
| template=ListingFields
 +
| introtemplate=ListingIntro
 +
| outrotemplate=ListingOutro
 +
| ?Description
 +
| ?PrettySince
 +
| ?PrettyRemoved
 +
}}
  
在LÖVE中你可以通过用简写代替那些倒霉的全名来在你的代码中重新定义那些烦人的函数:
+
== 类型 ==
 +
{{#ask: [[Category:Types]] [[parent::love (简体中文)]] [[Concept:Current]]
 +
| headers=hide
 +
| format=template
 +
| template=ListingFields
 +
| introtemplate=ListingIntro
 +
| outrotemplate=ListingOutro
 +
| ?Description
 +
| ?PrettySince
 +
| ?PrettyRemoved
 +
}}
  
 +
== 回调 ==
 +
=== 通用 ===
 +
{{#ask: [[Category:Callbacks]] [[Subcategory::General]] [[parent::love (简体中文)]] [[Concept:Current]]
 +
| headers=hide
 +
| format=template
 +
| template=ListingFields
 +
| introtemplate=ListingIntro
 +
| outrotemplate=ListingOutro
 +
| ?Description
 +
| ?PrettySince
 +
| ?PrettyRemoved
 +
}}
 +
 +
=== 窗口 ===
 +
{{#ask: [[Category:Callbacks]] [[Subcategory::Window]] [[parent::love (简体中文)]] [[Concept:Current]]
 +
| headers=hide
 +
| format=template
 +
| template=ListingFields
 +
| introtemplate=ListingIntro
 +
| outrotemplate=ListingOutro
 +
| ?Description
 +
| ?PrettySince
 +
| ?PrettyRemoved
 +
| ?PrettyDeprecated
 +
}}
  
<source lang="lua">
+
=== 键盘 ===
function love.load()
+
{{#ask: [[Category:Callbacks]] [[Subcategory::Keyboard]] [[parent::love (简体中文)]] [[Concept:Current]]
--你看这位仁兄用hamster就代替了后面那么老鼻子长的命令
+
| headers=hide
  hamster = love.graphics.newImage("hamster.png")
+
| format=template
  x = 50
+
| template=ListingFields
  y = 50
+
| introtemplate=ListingIntro
end
+
| outrotemplate=ListingOutro
function love.draw()
+
| ?Description
--你看到了没他在这用的时候就不用写那么老长了
+
| ?PrettySince
  love.graphics.draw(hamster, x, y)
+
| ?PrettyRemoved
end
+
| ?PrettyDeprecated
</source>
+
}}
  
== Modules|模块!少年!!还不点这!!!==
+
=== 鼠标 ===
{{#ask: [[Category:Modules]] [[parent::love (简体中文)]] [[Concept:Current]]
+
{{#ask: [[Category:Callbacks]] [[Subcategory::Mouse]] [[parent::love (简体中文)]] [[Concept:Current]]
 
| headers=hide
 
| headers=hide
 +
| format=template
 +
| template=ListingFields
 +
| introtemplate=ListingIntro
 +
| outrotemplate=ListingOutro
 
| ?Description
 
| ?Description
 +
| ?PrettySince
 +
| ?PrettyRemoved
 +
| ?PrettyDeprecated
 
}}
 
}}
== Types |类型?介个我暂时还没研究过...==
+
 
{{#ask: [[Category:Types]] [[parent::love (简体中文)]] [[Concept:Current]]
+
=== 手柄/控制杆 ===
 +
{{#ask: [[Category:Callbacks]] [[Subcategory::Joystick]] [[parent::love (简体中文)]] [[Concept:Current]]
 
| headers=hide
 
| headers=hide
 +
| format=template
 +
| template=ListingFields
 +
| introtemplate=ListingIntro
 +
| outrotemplate=ListingOutro
 
| ?Description
 
| ?Description
 +
| ?PrettySince
 +
| ?PrettyRemoved
 +
| ?PrettyDeprecated
 
}}
 
}}
== Callbacks|回调函数们 ==
+
 
{{#ask: [[Category:Callbacks]] [[parent::love (简体中文)]] [[Concept:Current]]
+
=== 触摸 ===
 +
{{#ask: [[Category:Callbacks]] [[Subcategory::Touch]] [[parent::love (简体中文)]] [[Concept:Current]]
 
| headers=hide
 
| headers=hide
 +
| format=template
 +
| template=ListingFields
 +
| introtemplate=ListingIntro
 +
| outrotemplate=ListingOutro
 
| ?Description
 
| ?Description
 +
| ?PrettySince
 +
| ?PrettyRemoved
 +
| ?PrettyDeprecated
 
}}
 
}}
 +
 +
 
[[Category:Modules]]
 
[[Category:Modules]]
{{#set:Description=The root module which contains all the other modules.}}
+
{{#set:Description=此模块包含所有其他模块.}}
 
{{#set:Since=000}}
 
{{#set:Since=000}}
  
== Other Languages |其他语言~我看你除了E文的还能看懂26个字母以外还能看懂哪国语言~==
+
== 其他语言 ==
 
{{i18n|love}}
 
{{i18n|love}}

Latest revision as of 06:23, 13 March 2020

当你开始用 LÖVE 编写游戏时, 需要了解几个最重要的 API 回调函数: love.load 仅执行一次,用于初始化加载你的游戏, love.update 用于管理你的游戏每一帧的状态, love.draw 用于渲染你的游戏到屏幕。

为了处理玩家输入的信息以及呈现一个全方面体验的游戏,很多交互将会重写额外的回调函数.

LÖVE 提供了默认的空回调函数,你可以通过对应的回调函数名在你自己的代码里重写这些函数:

-- 初始化矩形的一些默认值
function love.load()
    x, y, w, h = 20, 20, 60, 20
end

-- 每一帧增加矩形的尺寸
function love.update(dt)
    w = w + 1
    h = h + 1
end

-- 绘制有颜色的矩形
function love.draw()
    love.graphics.setColor(0, 100, 100)
    love.graphics.rectangle("fill", x, y, w, h)
end


注意:如果下面的列表为空或者缺少,说明还没有对应的中文翻译,欢迎贡献翻译。


模块

love.audio (简体中文) 提供一个用来创建音效的接口.
love.filesystem (简体中文) Provides an interface to the user's filesystem.
love.font (简体中文) 有了这个就可以用字体啦. Added since 0.7.0
love.graphics (简体中文) 绘制图形图片,管理屏幕显示.
love.image (简体中文) 为图像数据提供接口
love.keyboard (简体中文) Provides an interface to the user's keyboard.
love.math (简体中文) 提供平台无关的数学运算函数。
love.mouse (简体中文) 提供鼠标接口的模块.
love.physics (简体中文) 能够真实地模拟2D刚体的物理性质。 Added since 0.4.0
love.sound (简体中文) This module is responsible for decoding sound files.
love.system (简体中文) 提供对用户系统信息的访问。
love.thread (简体中文) Allows you to work with threads. Added since 0.7.0
love.window (简体中文) Provides an interface for the program's window.

第三方模块

函数

love.getVersion (简体中文) 获取当前 LÖVE 版本号。 Added since 0.9.1

类型

Data (简体中文) The superclass of all data.
Object (简体中文) The superclass of all LÖVE types.

回调

通用

Config Files (简体中文) Game configuration settings.

窗口

键盘

鼠标

手柄/控制杆

触摸


其他语言