-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcircuitActUtil.lua
55 lines (49 loc) · 1.77 KB
/
circuitActUtil.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
-----------------------------------------------------------------------------------------
--
-- circuitActUtil.lua
--
-- A utility file for common functions in the circuit act
--
-- Joe Cracchiolo
-----------------------------------------------------------------------------------------
------------------------- OverHead ---------------------------------------------------------
-- Get local reference to the game globals
local game = globalGame
--local act = game.newAct()
local util = {}
------------------------- Variables ---------------------------------------------------------
------------------------- Functions ---------------------------------------------------------
-- create the toolbox
function util.makeToolbox (act)
local toolbox = act:newImage ( "toolbox2.png", { width = 45, folder = "media/circuitActUtil" } )
toolbox.x = act.xMax - 30
toolbox.y = act.yMin + 30
transition.blink ( toolbox, { time = 2000 } )
return toolbox
end
-- function for the toolbox touch
function util:toolboxTouch (event)
if event.phase == "began" then
if toolWindow == nil then
if wrench then --- remove the wrech if there is already one on screen
wrench:removeSelf()
wrench = nil
end
transition.cancel( toolbox ) -- kill the blinking
toolbox.alpha = 1 -- set the alpha of the toolbox back to 1
toolWindow = display.newRect( act.group, act.xCenter, act.yCenter, 300, 300 )
wrench = act:newImage( "wrench.png", { width = 120 } )
wrench.rotation = 45
wrench.x = act.xCenter - 80
wrench.y = act.yCenter - 80
wrench.button = widget.newButton { width = 100, height = 100, onEvent = wrenchTouch }
wrench.button.x = act.xCenter - 80
wrench.button.y = act.yCenter - 80
end
end
return true
end
function util:printThis ()
print ("test")
end
return util