Game Development Community

Accessing Sprites In The Level Builder?

by David Taylor · in Torque Game Builder · 05/24/2006 (9:04 pm) · 6 replies

I'm using the level builder for the first time, and love the new point-and-click functionality. However, I have a query. How do I access the a static sprite that is in my level? I've placed a static sprite into my level, and now want to move it around by using the mouse.

I have an onMouseMove call that I know is registering, as I have placed an echo call within that function. But how do I 'get' the sprite in the level, and manipulate it via the mouse?

#1
05/24/2006 (10:11 pm)
Okay, I had a look in the Fish Tutorial, (very good tutorial, by the way), and have my sprite moving with the keyboard, but can't get the same to happen with the mouse, even though both are calling the same function. Can anyone point out to me where I've gone wrong?

function Player::onLevelLoaded(%this, %scenegraph)
{
    $player = %this;

    new ActionMap(mouseActionMap);

    mouseActionMap.bindCmd(keyboard, "w", "playerUpMove();", "playerUpStop();");

    mouseActionMap.bindCmd(mouse0, "xaxis", "playerUpMove();", "playerUpStop();");

    mouseActionMap.push();
}

function playerUpMove()
{
    $player.setLinearVelocityY( -15 );
}

function playerUpStop()
{
    $player.setLinearVelocityY( 0 );
}
#2
05/27/2006 (3:50 pm)
Try this, change this from
new ActionMap(mouseActionMap);
to
new ActionMap(moveMap);

Change these mouseActionMap to

moveMap

This might help as will
Torque 2D-Getting Started-ObjectSelection1Tutorial - TDN.htm
#3
05/27/2006 (7:16 pm)
No, that doesn't work, unfortunately.

That tutorial doesn't deal with action maps. I'm just confused. It works perfectly on the keyboard, but not the mouse...so bizarre...
#4
05/28/2006 (1:15 am)
David,

Have you read through the Input Interaction PDF in your documentation/reference folder? Instead of trying to bind the mouse to an Actionmap, it's probably better to handle mouse input through TGB's mouse event callbacks.

As for why it doesn't work, I can only offer a guess - the PDF shows that the mouse can use the .bind function (through an example) but perhaps not .bindCmd? Again, I'd just save myself the hassle and use the mouse event callbacks.
#5
05/28/2006 (2:32 am)
I tried this out for myself actually and it appears you can't bind the mouse at all using Actionmaps. Button clicks, x-axis movement, nothing registers with .bind() or .bindCmd().

Even the example from the PDF doesn't work. So it looks like the event callbacks are your only choice now.
#6
05/28/2006 (3:57 am)
Ah, so that was a pretty misleading tutorial in that regard, then, hehe!

Thanks, Mike. I'm using onMouseMove and it works fine. I'd just hoped binding it would work. Ah well, sae la vie! ;)

Many thanks! :)