love2d ffi 窗口移动
内置的窗口位置函数会重载窗口,于是自己造一个,直接调用winapi就行了。
写的时候可以简化一点,指针都用 void*
即可。
local ffi = require("ffi")
ffi.cdef[[
void* GetActiveWindow();
int GetSystemMetrics(int f);
int SetWindowPos(void *h, int z, int x, int y, int cx, int cy, int f);
]]
local function getResolution()return ffi.C.GetSystemMetrics(0), ffi.C.GetSystemMetrics(1)
end
local function setPosition(x, y)ffi.C.SetWindowPos(ffi.C.GetActiveWindow(), 0, x, y, 0, 0, 0)
end
local sin, cos = math.sin, math.cos
local scrw, scrh = getResolution()
local winw, winh = love.graphics.getWidth(), love.graphics.getHeight()
local ox, oy = (scrw-winw)/2, (scrh-winh)/2
local t = 0
function love.update()t = t+.1setPosition(ox+200*cos(t), oy+100*sin(t))
end
love2d ffi 窗口移动相关推荐
- love2d教程3--输入和音乐
love2d的输入包括love.keyboard,love.mouse,love.joystick(手柄) 键盘: 按键检测是否按下可以用love.keyboard.isDown("键值&q ...
- Love2D游戏引擎制作贪吃蛇游戏
预览游戏 love2d游戏引擎重要函数 详情: love.load:当游戏开始时被调用且仅调用一次 love.draw:回调函数,每帧更新一次游戏画面 love.update:回调函数,每帧更新一次游 ...
- Mac 下安装使用 Love2D
2019独角兽企业重金招聘Python工程师标准>>> Mac 下安装使用 Love2D 概述 Love2D 是一款开源的 2D 开发引擎, 使用 Lua, 支持Windows,Li ...
- idea中如何打开RunDashboard窗口,微服务最实用设置
idea中如何打开RunDashboard窗口 找到.idea目录,打开workspace.xml,搜索RunDashboard,找到该段配置,加入下面注释中的代码 <component nam ...
- 使用JS/Jquery获得父窗口的几个方法(笔记)
<pre name="code" class="javascript">取父窗口的元素方法:$(selector, window.parent.do ...
- leetcode 30. Substring with Concatenation of All Words 与所有单词相关联的字串 滑动窗口法
题目描述 给定一个字符串 s 和一些长度相同的单词 words.在 s 中找出可以恰好串联 words 中所有单词的子串的起始位置. You are given a string, s, and a ...
- leetcode 567. Permutation in String 字符串的排列 滑动窗口法
题目 给定两个字符串 s1 和 s2,写一个函数来判断 s2 是否包含 s1 的排列.换句话说,第一个字符串的排列之一是第二个字符串的子串. 示例1:输入: s1 = "ab" s ...
- leetcode Longest Substring with At Most Two Distinct Characters 滑动窗口法
题目解析 代码如下 题目解析 这一题是一道会员的题目,题目介绍如下: Given a string, find the length of the longest substring T that c ...
- leetcode 3. Longest Substring Without Repeating Characters 最长非重复子串的长度 滑动窗口法
题目链接 根据我们之前介绍的滑动窗口法的解法: 滑动窗口法详解 leetcode 438. Find All Anagrams in a String 滑动窗口法 这题,我们不难解决,使用之前的模板. ...
- leetcode 438. Find All Anagrams in a String 滑动窗口法
题目链接 解析 主要使用滑动窗口法解题,需要好好体会的是中间的两个判断couter的用法,这里很巧妙. 如果想了解更多的滑动窗口法内容,看这里: 滑动窗口法详解 代码 from collections ...
最新文章
- 像这样的作业调度器,你会怎么设计?
- 海量数据库解决方案2011030101
- 理论基础 —— 排序
- mysql更新数据库中int 1_Mysql数据库int(1)和tinyint(1)的区别扩展阅读
- 并发视频,怎么hold住高并发
- IBatisNet之获取和操作SQL语句
- 用算法去扫雷(go语言)
- 能直接替代替换RC522/CV520的13.56MHz高频读写芯片,太棒了
- Tyvj 1728 普通平衡树
- 电子或通信领域当前的主流技术及其社会需求调查
- [feather]StarlingUi框架——初识feather、界面启动及Ui加载
- 基于VC面部识别软件(识别出人脸特征)
- ElasticSerach7.15.2插件中文分词器(IK+pinyin)
- 【GIS开发】地理编码服务Geocoder(Python)
- Android 双usb 摄像头支持
- 谷歌X最新开源任务驱动的类级别机器人抓取CaTGrasp!
- 临床执业助理医师(综合练习)题库【9】
- Database---Access Methods
- Android /iPhone/iPad UI之常用图标尺寸规范
- DS1307驱动代码