Game Development Community

Does this make sense

by rennie moffat · in General Discussion · 08/06/2009 (7:40 pm) · 5 replies

I am trying to code, I am a rook to the nth degree. however, what I am wondering is does this code make sense?

function cube::onLevelLoaded(%this, %scenegraph)
{
    $cube = %this;
    %this.setUseMouseEvents(true);
    %this.getUseMouseEvents(true);
}

The reason I ask is becasue onLevelLoaded I want my playerClass (cube) to use mouse events to determine its movement, where it will go, so "set" (true), I would think "get" should be involved to, as it must retrieve the event info. Am I right?

The documentation, they are defined as follows...
setMouseEvent: Sets whether or not mouse events are monitored by this object.
getMouseEvent: Gets whether or not mouse events are being monitored by this object.

About the author

My thanks to Garage Games and the Garage Games Community combined with owned determination I got one game up, Temple Racer and I am looking to build more interesting, fun games for the mass market of the iOS app store.


#1
08/06/2009 (7:52 pm)
You don't need the getMouseEvents() call as it is only used to get figure out whether the object is currently monitoring mouse events.
#2
08/06/2009 (8:05 pm)
would you be able to give me an example of where one might use getMouseEvents?
#3
08/12/2009 (12:37 pm)
function cube::onLevelLoaded(%this, %scenegraph)
{
    $cube = %this;

    if(!$cube.getUseMouseEvents())
    {
         %this.setUseMouseEvents(true);
    }    
}
So this will check if $cube is using mouse events and if it's not ( ! ) then it sets it so it is.

`Patrick
#4
08/12/2009 (12:43 pm)
why would you include an if statement in this?



#5
08/12/2009 (1:33 pm)
because getUseMousevents() returns a value. Either true or false, depending on if the mouse events are enabled on that object.

So...

if $cube is not using mouse events then set it to use mouse events.