I have a text label which I made invisible by checking the “invisible” button for the font, and I’d like to make it visible when mouse rollover the item it’s describing. How to make it now visible? I have the rest of the mouseover functioning to draw a line to the text when an object is rolled over, it’s just making the text visible I can’t figure out how to do.
(Later I’ll ask about making an “associative list”(?) so that proper label for each object rolled over will show.)
@ Patricia3d, thanks, but I’m not sure what that means.
@ Monster, I’m doing this in a script, because the mouse may rollover any object, which the script picks up, & I think (or thought) I have that part working, so I’m not sure how to use an actuator in concert with the script.
script:
import Rasterizer as r
import GameLogic as g
objects = g.getCurrentScene().objects
# SET FONT INVISIBLE, LATER TRY TO MAKE IT VISIBLE ON MOUSEOVER, any object
# trying to get whatever is rolled over, to make line to label:
# get controller
c = g.getCurrentController()
# get object which is attached to the controller
o = c.owner
# Get the sensor by the name "MouseOver" which is attached to the controller
mOver = c.sensors["MouseOver"]
# get the hit object
new = mOver.hitObject
#contRolloverObject = g.getCurrentController()
#own = contRolloverObject.getOwner
print "before rollover object"
print new
print "after object"
#pointA = own.position
pointA = new.position #objects[own].position
pointB = objects["OBFont"].position
color = (0,1,0)
#objects["OBFont"].setvisible(1) # not right way to set it visible
r.drawLine(pointA, pointB, color)
Oh I didn’t read your post complete, It was for game ( I am answreing for Animation ) In Animation You can create IPO curve for the Visibility channel. Sorry for confusion
Thank you Nezgar, that was my own thread, but I hadn’t tried to implement the text vis/invis yet, just the change color of the object, now I’ll look more closely;
looks like: make font child of object, then:
child = new.children
if str(child) != “[]”:
child[0].visible = True
I’ll try that.
(edit)
but that won’t work because I now see that I deliberatly did NOT have the font be a child of the object, so that I could make the font STAY IN ONE PLACE, and NOT MOVE/ROTATE with the rotation of the objects. But maybe I can use some of the idea, I’ll see…
Whoops, i’m sorry. I didn’t noticed that was your own thread :o. I was just searching over many threads to find those .blend files again, because i thaught they can gave you some clues.
No problem, I hadn’t tried to implement the text vis/invis at that time, but your reference to it either did give me a clue, or at least led me to persevere, and I now have a partial solution! I wrote another separate script for vis/invis the text, since I couldn’t find a way to use the existing sensor for vis/invis while it was set up already for drawing a line to the text.
But, it only does vis/invis for one font/text, for two different objects, so now I’ll try first to make it do a couple of fonts for two objects, via dict I think, and see if I can make a bunch of associations on import to do many more.