Easy Positioner (ssk.easyPositioner.*)
This module gives you the ability to add a basic editor to any game or app while you are working on it.
Once the 'easy positioner' is attached to an object you can:
- Click on that object to select it,
- Drag that object around the screen,
- Move the object using the arrow keys,
- Change the move scale for keys from sub-pixel to up to 10-pixels per key press, and
- Snap objects together.
The tool also provides a small floating dialog that shows the current position of the selected object.
At the end of the day, the purpose of this tool is to allow you to, (in- game/app) modify the positions of elements, get the updated value, then quickly type that into your code. i.e. No more do you have to adjust in code, re-run, adjust again, re-run again, ....
ssk.easyPositioner.start()
Before you can use the Easy Positioner tool, you need to initialize/start it.
ssk.easyPositioner.start( )
ssk.easyPositioner.stop()
If you need to, you can stop the tool, but before using it again (say in another scene), you need to call start()
again.
Note: I don't personally use this feature because I only ever run the tool while editing. It isn't meant to be embedded and available in a live app. However, you may want to enable it and use it on a device and this will let you stop it once started.
ssk.easyPositioner.stop( )
ssk.easyPositioner.attach()
Before you can interact with an object it must be 'attached' to the easyPositioner logic.
ssk.easyPositioner.attach( obj )
obj
- Display object to be attached to the easy positioner system.
ssk.easyPositioner.start()
local smiley = newImageRect( group, centerX, centerY, "images/smiley.png", { size = 80 })
local rg = newImageRect( group, centerX - 100, centerY, "images/rg256.png", { size = 80 })
local corona = newImageRect( group, centerX + 100, centerY, "images/corona256.png", { size = 80 })
ssk.easyPositioner.attach( smiley )
ssk.easyPositioner.attach( rg )
ssk.easyPositioner.attach( corona )
ssk.easyPositioner.setMoveBy()
By default, the easy positioner uses this move-by table: { 0.25, 0.5, 1, 2, 5, 10 }
, but you can have any values you want. This function lets you set the options you need.
ssk.easyPositioner.setMoveBy( newMoveBy )
newMoveBy
- A table of move-by values.
-- Change move-by options to: 1, 2, 5, 10, 20, and 50 pixels.
ssk.easyPositioner.setMoveBy( { 1, 2, 5, 10, 20, 50 } )
Snapping
To snap object A to object B, do the following:
- Click on object A
- Tap
s
key till you see the snaping style you want in the dialog-bubble. - Click on object B.
Keyboard Map
In addition to using the mouse to select and drag objects, you can use the keyboard to move the currently selected object, to snap objects, to change the move-by settings, and to undo the last snap or keyboard movement.
Note For Windows Users: Be sure you are simulating an android or custom device. The simulated iOS devices ignore keystrokes.
Function | Summary |
---|---|
left arrow |
Move currently selected object left, by current 'move-by' value. |
right arrow |
Move currently selected object right, by current 'move-by' value. |
up arrow |
Move currently selected object up, by current 'move-by' value. |
down arrow |
Move currently selected object down, by current 'move-by' value. |
SHIFT + arrow key |
Move in selected direction at 10 times the current 'move-by' value. |
TAB |
Select next 'move-by value'. New value shown in dialog bubble. |
s |
Select next 'snap mode': "off", "leftcenter", "rightcenter", "centertop", "centerbottom", "middle" . |
SHIFT + s |
Turn off snapping. |
u |
Undo last non-drag move. i.e. You can undo the very last snap or keyboard movement. |
Copyright © Roaming Gamer, LLC. 2008-2016; All Rights Reserved