Spawn an object with a mouse click
by Kayrel Parcen Vandal · in TGB Platformer Kit · 10/24/2008 (6:20 am) · 2 replies
Hi, people:
Have anybody done a script spawning and object using the mouse? I trying to make some kind of painting game inside the PSK where I am using one object as a brush and it will spawn objects (inks) using the mouse. If anybody have some directions or suggestions?
thanks.
Have anybody done a script spawning and object using the mouse? I trying to make some kind of painting game inside the PSK where I am using one object as a brush and it will spawn objects (inks) using the mouse. If anybody have some directions or suggestions?
thanks.
#2
With P.O.'s help I did this little code to paint during the game. The actors respond to the paint's collision perfectly in a game without the PSK. In the PSK they ignore it. Using the PSK's ObjectManager.cs setObjectType set to SolidPlatform the PSK's actors responded, but not as the SolidPlatform's behavior does. The actor respond as slope, wall or platform, but they stay as in air. Only side movement is allowed. There is no on ground reset for jumping or running. I am sure there is more to it then just setting its type. But what and where. If someone can point the way.
Thanks.
function sceneWindow2D::onRightMouseDragged( %this, %mod, %worldPos, %mouseClicks )
{
echo("Mouse Dragging");
%this.mousePos = %worldPos;
echo(%worldPos);
%inkObject = new t2dStaticSprite()
{
SceneGraph = %this.getSceneGraph();
ImageMap = inkImageMap;
Position = %worldPos;
};
%inkObject.setSize( ".5 .5" );
%inkObject.setCollisionActive(false, true);
%inkObject.setCollisionDetection( full );
%inkObject.setCollisionCallback( true );
%inkObject.enableUpdateCallback();
// So the PSK ObjectManager.cs acknowledge the paint
%inkObject.setObjectType("SolidPlatform");
}
Thanks.
10/27/2008 (11:21 am)
Hello People:With P.O.'s help I did this little code to paint during the game. The actors respond to the paint's collision perfectly in a game without the PSK. In the PSK they ignore it. Using the PSK's ObjectManager.cs setObjectType set to SolidPlatform the PSK's actors responded, but not as the SolidPlatform's behavior does. The actor respond as slope, wall or platform, but they stay as in air. Only side movement is allowed. There is no on ground reset for jumping or running. I am sure there is more to it then just setting its type. But what and where. If someone can point the way.
Thanks.
function sceneWindow2D::onRightMouseDragged( %this, %mod, %worldPos, %mouseClicks )
{
echo("Mouse Dragging");
%this.mousePos = %worldPos;
echo(%worldPos);
%inkObject = new t2dStaticSprite()
{
SceneGraph = %this.getSceneGraph();
ImageMap = inkImageMap;
Position = %worldPos;
};
%inkObject.setSize( ".5 .5" );
%inkObject.setCollisionActive(false, true);
%inkObject.setCollisionDetection( full );
%inkObject.setCollisionCallback( true );
%inkObject.enableUpdateCallback();
// So the PSK ObjectManager.cs acknowledge the paint
%inkObject.setObjectType("SolidPlatform");
}
Thanks.
Associate Phillip O'Shea
Violent Tulip
function t2dSceneWindow::onMouseDragged(%this, %modifier, %worldPosition, %clicks) { %myObject = new t2dStaticSprite() { SceneGraph = %this.getSceneGraph(); ImageMap = myImageMap; Position = %worldPosition; }; }Just replace the actual object with something that you want to spawn ;)