08 2012 档案
摘要:本文转自:http://www.cnblogs.com/whiteyun/archive/2009/09/02/1541043.html在string库中功能最强大的函数是:string.find(字符串查找)string.gsub(全局字符串替换)string.gfind(全局字符串查找)string.gmatch(返回查找到字符串的迭代器)这些函数都是基于模式匹配的。与其他脚本语言不同的是,Lua并不使用POSIX规范的正则表达式[4](也写作regexp)来进行模式匹配。主要的原因出于程序大小方面的考虑:实现一个典型的符合POSIX标准的regexp大概需要4000行代码,这比整个Lua
阅读全文
摘要:lua中有一个全局的表,_G,这个表包含了所有的全局变量.例如:a = 123;d = {a,444};这样的两个变量实际上就会被lua存储到_G表中去.也就是说_G["a"]就是变量a._G["a"] = _G["d"];这样的语句和a=d;是完全一样的.当然,既然_G也是一个表,那么我们就可以设置_G表的__index等函数来达到控制_G表的访问权限了.当然我们也可以用__newindex来防止创建新的全局变量(至于怎么做:只要在函数里调用error()函数来输出一个错误就行了,这样就可以避免创建新的全局变量,但是一般没必要这么做
阅读全文
摘要:table是lua中的唯一的一个数据结构.而且,table中的数据可以是任意类型的,当然也可以是函数类型.例如:a = {};-->声明一个tablea[1] = function() print("a"); end; -->这样就给a[1]赋予了一个函数.也就是说,table里可以存储各种各样的东西.同时如果a[2] = a;-->这也是可行的,但是注意,lua中的这种赋值用法得到的结果其实是: a[2]是a的引用,而并非把a的内容都复制给a[2].也就是说,一个table中既可以有数据,也可以有函数.而Metatables(元表)其实也是一个table
阅读全文
摘要:Lua的语法实际上和c的语法很接近,看起来也比较的简洁.(Lua5.1版本)Lua的关键字如下: and break do else elseif end false for function if in local nil not or repeat return then true until whileLua的基本符号如下: + - * / % ^ # == ~= <= >= < > = ( ) { } [ ] ; : ...
阅读全文
摘要:HGE本身并不支持中文的显示,因此我使用由 微妙的平衡 大神提供的解决方案.大神提供的代码本来包含gfxfont.h和gfxfont.cpp文件,只需要将这两个文件添加到工程中即可使用.但是我实在太懒,为了避免每次都添加两个文件到工程中去,于是我擅自将cpp的代码全部移到了.h文件中并做了一些细微的改动.这样每次使用的时候就只需要将gfxfont.h引入工程就够了,当然我把这个gfxfont.h直接放到了hge的include文件夹中,这样我就可以直接用#include <gfxfont.h>来引用这个文件了.(当然,要先hge的include目录添加到工程中去.)以下是gfxfo
阅读全文
摘要:1 /* 2 ** Haaf's Game Engine 1.8 3 ** Copyright (C) 2003-2007, Relish Games 4 ** hge.relishgames.com 5 ** 6 ** hge_tut08 - The Big Calm 7 */ 8 9 10 // 复制"font2.fnt","font2.png","objects.png" 11 12 13 // 本教程模拟了太阳和月亮的运转,以及天空和海面的情况 14 15 16 #include <math.h> 17 1
阅读全文
摘要:1 /* 2 ** Haaf's Game Engine 1.8 3 ** Copyright (C) 2003-2007, Relish Games 4 ** hge.relishgames.com 5 ** 6 ** hge_tut07 - Thousand of Hares 7 */ 8 9 10 // 复制"font2.fnt", "font2.png","bg2.png","zazaka.png" 11 12 13 #include <hge.h> 14 #include <hg
阅读全文
摘要:1 /* 2 ** Haaf's Game Engine 1.7 3 ** Copyright (C) 2003-2007, Relish Games 4 ** hge.relishgames.com 5 ** 6 ** Tutorial 06 - Creating menus 7 */ 8 9 // 文件名:menuitem.h,自定义控件类的声明10 11 #include <hge.h>12 #include <hgegui.h>13 #include <hgefont.h>14 #include <hgecolor.h>15 #p
阅读全文
摘要:1 /* 2 ** Haaf's Game Engine 1.8 3 ** Copyright (C) 2003-2007, Relish Games 4 ** hge.relishgames.com 5 ** 6 ** hge_tut05 - Using distortion mesh 7 */ 8 9 10 // 复制"particles.png","menu.wav","font1.fnt","font1.png","trail.psi" 11 12 13 14 #include
阅读全文
摘要:1 /* 2 ** Haaf's Game Engine 1.8 3 ** Copyright (C) 2003-2007, Relish Games 4 ** hge.relishgames.com 5 ** 6 ** hge_tut04 - Using render targets 7 */ 8 9 10 // 复制"particles.png","menu.wav","font1.fnt","font1.png"以及"trail.psi" 11 12 13 #include <
阅读全文
摘要:1 /* 2 ** Haaf's Game Engine 1.8 3 ** Copyright (C) 2003-2007, Relish Games 4 ** hge.relishgames.com 5 ** 6 ** hge_tut03 - Using helper classes 7 */ 8 9 10 // 从"precompiled"目录下复制"particles.png","menu.wav","font1.fnt" 11 // "font1.png"以及"trai
阅读全文
摘要:1 /* 2 ** Haaf's Game Engine 1.8 3 ** Copyright (C) 2003-2007, Relish Games 4 ** hge.relishgames.com 5 ** 6 ** hge_tut02 - Using input, sound and rendering 7 */ 8 9 10 // 请从 "precompiled"文件夹下复制"particles.png"和"menu.wav" 11 // 到程序文件夹下.当然hge.dll和bass.dll也是需要复制的. 12 13
阅读全文

浙公网安备 33010602011771号