Log In  
Log In  

Cart [#51485#] | 2018-04-10 | License: CC4-BY-NC-SA | Embed
2

This is a simple mouse over text detection example.
Made it to help someone else's question but figured I'd post it here.

Also this isn't optimized, I tried to make it more for learning than optimization.
For instance:

function _mot(_t) 
--if mouse is within the text
-- boundaries then set that 
-- text.over to equal true
 if(_mx>=_t.x and _mx<(_t.x+(#_t.str*4)-1) and _my>=_t.y and _my<(_t.y+5) ) then
  _t.over = true
 else
  _t.over = false
 end
end

Could be easily simplified to:

function _mot(_t) 
--if mouse is within the text
-- boundaries then set that 
-- text.over to equal true
 _t.over=(_mx>=_t.x and _mx<(_t.x+(#_t.str*4)-1) and _my>=_t.y and _my<(_t.y+5) )
end

Everything is commented best I could, but feel free to ask questions if any arise.

P#51486 2018-04-10 07:04 ( Edited 2018-06-01 18:01)

This is awesome! You could use this in a game and it would probable get very popular.

P#53188 2018-06-01 14:01 ( Edited 2018-06-01 18:01)

[Please log in to post a comment]

X
About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2018-12-15 10:55 | 0.019s | 2097k | Q:20