This site requires JavaScript, please enable it in your browser!
Greenfoot back
actinium
actinium wrote ...

2012/12/5

mouseover

actinium actinium

2012/12/5

#
is there anyway to mimic the mouse hovering over a point or an actor. i tried using mousMoved but its a bit limited.
danpost danpost

2012/12/5

#
Do you mean like the MseActBar and SwitchBar in my Bar SubClasses scenario?
Zamoht Zamoht

2012/12/5

#
I did it like this and it should work
public void act() 
    {
        if (Greenfoot.mouseMoved(this) && info == null)
        {
            info = new AttributeInfo(attribute, effect);

            getWorld().addObject(info, getWorld().getWidth() / 2, 80);
        }
        else if (Greenfoot.mouseMoved(null) && !Greenfoot.mouseMoved(this))
        {
            getWorld().removeObject(info);
            info = null;
        }
    }  
Okay so here I've declared info to be a public AttributeInfo (one of my classes). This works so when i hold the mouse over this object it adds an other, when you remove the mouse from the object, the added object is removed. Since I don't know what you want to happen when the mouse is over something this is the best I can give you for now.
actinium actinium

2012/12/5

#
That worked perfectly, thanks.
You need to login to post a reply.