Your DesktopX Documentation Resource Guide

Documentation Home

Quick Start

User's Guide

Developer's Guide

Resources

Tutorials


Making objects that move other objects

By Brad Wardell

 

Today I'm going to create a set of objects that allow you to control the position of another object.  In essence, I am going to make 4 objects that will act as up, down, left, and right and then the cursor object that will be what is being controlled by the others.

Step 1: Create the first object.

 

Step 2: Go to its properties.

 

Step 3: Change its image to be an arrow.

 

Step 4: Create the target object and give it an image too.

Step 5: Give this object a name.

 

Step 6: Go back to your original object and create  new script for it.

 

Step 7: Using the scripting guide located here: http://www.stardock.com/products/desktopx/docs/3x/DXScripting.doc Link have this object take over the mouse button down message.

You will find that the what you want to add is something like this:

 

Function Object_OnLButtonDown(x, y)
  DesktopX.Object("TargetObject").bottom = DesktopX.Object("TargetObject").bottom - 10
End Function
 

Step 8: Clone your control object 3 more times and make a couple tweaks so that they are down, left and right buttons.

For example, I want to use the same up arrow graphic but I need it to point right. So I rotate it 90 degrees. For the down one I would rotate it 180 degrees and the one pointing left I would rotate is 270 degrees..

 

Sub Object_OnScriptEnter
  Object.Rotation = 90
End Sub
 

Then I change what is being done to the target object based on which button. For example, the button moving it to the right would have this code:

 

You're done!

And voila. There you go.  I'll now export it and upload it for yourself.  If you have DesktopX Pro, you could export it as a stand-alone program to send to anyone whether they have DesktopX or not.

 

Download sample here.


7/29 

SkinStudio 6.2 Released

7/25 

A God Has Fallen - New Demigod Trailer Released

7/24 

Sins of a Solar Empire v1.1 Beta has Arrived

7/23 

Stardock Releases New WindowBlinds 6.2 Update

7/22 

Stardock Releases The Political Machine v1.04 with New Characters

7/22 

Stardock Releases MyColors 2.5

7/17 

DesktopX 3.5 Officially Released

7/11 

Corel WinDVD 9 and Painter X Now Available on Impulse!