博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
LOVE2D-03-完整的LOVE2D程序
阅读量:7051 次
发布时间:2019-06-28

本文共 2773 字,大约阅读时间需要 9 分钟。

一个完整的love2d源码包含2个基本的lua文件

main.lua  和  conf.lua

-------------------------------------------------------------------------------------------------------------------------------------------

conf.lua主要是对游戏程序的不必要的一些其他管理,如窗口大小,窗口标题,是否全屏,鼠标样式等等

man.lua主要是整个游戏的灵魂文件,所有资源的加载定义都必须在这个文件中完成,当然,也可以调用外部lua文件,和其他的文件。

-------------------------------------------------------------------------------------------------------------------------------------------

conf.lua会被首先执行,

-------------------------------------------------------------------------------------------------------------------------------------------

conf.lua 常用配置

function love.conf(win)--设置标题和窗口大小win.title = "My Love APP" win.screen.width = 800win.screen.height = 600end

conf.lua 默认配置项

  使用conf.lua主要是管理游戏加载时的一些加载资源的管理

其中最主要的时conf.lua用来管理模块的加载与禁用,以提升游戏的加载速度,如:

function love.conf(win)win.title = "Untitled" -- The title of the window the game is in (string)win.author = "Unnamed" -- The author of the game (string)win.url = nil -- The website of the game (string)win.identity = nil -- The name of the save directory (string)win.version = "0.8.0" -- The LÖVE version this game was made for (string)win.console = false -- Attach a console (boolean, Windows only)win.release = false -- Enable release mode (boolean)win.screen.width = 800 -- The window width (number)win.screen.height = 600 -- The window height (number)win.screen.fullscreen = false -- Enable fullscreen (boolean)win.screen.vsync = true -- Enable vertical sync (boolean)win.screen.fsaa = 0 -- The number of FSAA-buffers (number)win.modules.joystick = true -- Enable the joystick module (boolean)win.modules.audio = true -- Enable the audio module (boolean)win.modules.keyboard = true -- Enable the keyboard module (boolean)win.modules.event = true -- Enable the event module (boolean)win.modules.image = true -- Enable the image module (boolean)win.modules.graphics = true -- Enable the graphics module (boolean)win.modules.timer = true -- Enable the timer module (boolean)win.modules.mouse = true -- Enable the mouse module (boolean)win.modules.sound = true -- Enable the sound module (boolean)win.modules.physics = true -- Enable the physics module (boolean)end

  但是绝不能禁止love.filesystem模块和love模块,如果禁止,在main.lua中就无法用love进行函数回调或调用,love.filesystem则是提供一个接口给用户的文件系统。

 

 main.lua常用函数

function love.load() --资源加载回调函数,仅初始化时调用一次endfunction love.draw() --绘图回调函数,每周期调用endfunction love.update(dt) --更新回调函数,每周期调用endfunction love.keypressed(key) --键盘检测回调函数,当键盘事件触发是调用end

 main.lua所有回调函数

love.draw    love.focus    love.joystickpressed    love.joystickreleased    love.keypressed    love.keyreleased   love.load    love.mousepressed   love.mousereleased    love.quit   love.run  love.update

  在以后将专门开设一篇文章来专门进行解释love2D中的所有函数

转载于:https://www.cnblogs.com/releed/p/6350146.html

你可能感兴趣的文章
hadoop datanode 不能连接 namenode
查看>>
VyOS--企业软路由推荐
查看>>
node.js 在window下安装
查看>>
CentOS 7打开文件中文乱码
查看>>
Winform动态创建控件对DPI的处理
查看>>
new关键字与malloc的区别
查看>>
《Just For Fun》阅读摘抄
查看>>
hibernate4.3.5.Final入门1
查看>>
python 发送邮件模块
查看>>
unqlite安装/使用/测试
查看>>
SQLite 查询或更新上一条插入的数据
查看>>
Ansible 之 roles使用
查看>>
我的友情链接
查看>>
OpenCV+Dlib进行实时脸部检测
查看>>
【Android】简单的日志工具
查看>>
8月初.wang域名总量TOP14:35互联耐思尼克竞争激烈
查看>>
解决wordpress上传文件2M限制
查看>>
读《学习正则表达式》(1)
查看>>
482. License Key Formatting - LeetCode
查看>>
AWK常用命令总结
查看>>