Hi folks,
while analyzing the LUA tables of a running gideros script, I stumbled over a nice feature. The ability to set the blend mode for a sprite. AWESOME!!!
Here is a little script that shows a spot light running over the gideros logo.
Enjoy
Michael
zip
zip
Comments
run very very very smooth!
cool!!!
www.tntengine.com
What does the smiley face mean? (ndoss is hoping gorkem is kidding)
The main reason why this isn't documented is that I was planning to replace it with an easier one like:
sprite:setBlendMode(ADD) or
sprite:setBlendMode(MULTIPLY)
About glBlendFunc, even though there are many combinations that you can use, only a few of them are common and useful
main.lua:43: attempt to index global 'BlendFactor' (a nil value)
Is that because it is being worked on?
My apps: http://www.yummyyellow.com
Undocumented BlendFactor and setBlendFunc was removed and Sprite:setBlendMode was added instead. I can modify the @MikeHart's example and post a new one here.
Likes: atilim
My apps: http://www.yummyyellow.com
cheers
evs
Now I'm really confused. maybe this is something in Lua I don't understand. So when you type "mask.speedX = 2", you are actually creating a new variable?? I thought you would have to use "local" or something like that. So you can just create variables on the fly? This shows how new I am to lua.
As Mike said, you can add any variable (or function) to the app (or any table) at any time.
If you prefix a variable with the word local then it's scope is the current block (chunk) it's defined in, otherwise it becomes a global variable.
You have to be really careful with languages like lua, because you'll not get any warning if you misspell a variable name or accidentally make a variable global and the bugs that it causes can be VERY hard to track down.
In a language that was designed to be embedded within another program and used to add scripting functionality to said program you can sort of see why the extra overhead of checking these kinds of things wasn't needed (that's the job of the compiler normally), however as soon as you start to use it for fully fledged app development in it's own right then your out on your own. Proceed with caution!
#MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
You can use this to look at mask (or any table's) contents to try to understand what's going on under the hood:
dirX 1
speedX 2
speedY 1
dirY 1
__userdata userdata: 0x1086985b8
where __userdata will be the original mask (Bitmap)
cheers
evs
#MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
cheers
evs
Now where's that straitjacket :P
cheers
evs
#MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
local inspect = require 'inspect'
foo = Sprite.new();
print (inspect(foo));
You can see all the goodies inside. I put inspect.lua and other handy utilities in my init.lua for easy maintenance. Thank you @atilim and @MikeHart - I was wondering what those constants were inside Sprite()... great stuff.
- Ian
I also use this...
cheers
evs