Web
Analytics
Log In  

2

Cart [#51485#] | Copy | Code | 2018-04-10 | Link
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 14: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

Log in to post a comment

user:
password:

New User | Account Help
:: New User
X
About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2018-07-19 17:22 | 0.223s | 1572k | Q:18