Hi there,
What would be the quickest way to visually vibrate an object given two parameters (amplitude, frequency)?
Thank you
Kaan. [import]uid: 99031 topic_id: 32437 reply_id: 332437[/import]
Hi there,
What would be the quickest way to visually vibrate an object given two parameters (amplitude, frequency)?
Thank you
Kaan. [import]uid: 99031 topic_id: 32437 reply_id: 332437[/import]
Is this the kind of thing you are thinking about?
If so, this is the basic code for it:
createVibroids = function ( parentGroup, x, y )
local parentGroup = parentGroup or display.getCurrentStage()
local vibrateGroup = display.newGroup()
parentGroup:insert(vibrateGroup)
local vibrate1
local vibrate2
vibrate1 = function( obj )
if not (obj and type(obj.removeSelf) == "function") then
return
end
transition.to( obj, { xScale = obj.amplitude, yScale = obj.amplitude, time = 1000/obj.frequency, onComplete=vibrate2 } )
end
vibrate2 = function( obj )
if not (obj and type(obj.removeSelf) == "function") then
return
end
transition.to( obj, {xScale = 1/obj.amplitude, yScale = 1/obj.amplitude, time = 1000/obj.frequency, onComplete=vibrate1 } )
end
local block = display.newRect(vibrateGroup, 0, 0, 50, 50 )
block.amplitude = 1.25
block.frequency = 2
vibrate1(block)
block = display.newRect(vibrateGroup, 150, 0, 50, 50 )
block.amplitude = 2
block.frequency = 1
vibrate1(block)
block = display.newRect(vibrateGroup, 300, 0, 50, 50 )
block.amplitude = 2
block.frequency = 10
vibrate1(block)
vibrateGroup:setReferencePoint(display.CenterReferencePoint)
vibrateGroup.x,vibrateGroup.y = x,y
return vibrateGroup
end
You can see the whole demo by grabbing SSKCorona and/or by downloading a binary onto your Android/Fire/Nook (sorry now iOS binaries).
[import]uid: 110228 topic_id: 32437 reply_id: 129000[/import]
Note: I pulsed the scale of the objects, but you could just as easily jiggle them left and right or up and down.
-Ed [import]uid: 110228 topic_id: 32437 reply_id: 129001[/import]
Is this the kind of thing you are thinking about?
If so, this is the basic code for it:
createVibroids = function ( parentGroup, x, y )
local parentGroup = parentGroup or display.getCurrentStage()
local vibrateGroup = display.newGroup()
parentGroup:insert(vibrateGroup)
local vibrate1
local vibrate2
vibrate1 = function( obj )
if not (obj and type(obj.removeSelf) == "function") then
return
end
transition.to( obj, { xScale = obj.amplitude, yScale = obj.amplitude, time = 1000/obj.frequency, onComplete=vibrate2 } )
end
vibrate2 = function( obj )
if not (obj and type(obj.removeSelf) == "function") then
return
end
transition.to( obj, {xScale = 1/obj.amplitude, yScale = 1/obj.amplitude, time = 1000/obj.frequency, onComplete=vibrate1 } )
end
local block = display.newRect(vibrateGroup, 0, 0, 50, 50 )
block.amplitude = 1.25
block.frequency = 2
vibrate1(block)
block = display.newRect(vibrateGroup, 150, 0, 50, 50 )
block.amplitude = 2
block.frequency = 1
vibrate1(block)
block = display.newRect(vibrateGroup, 300, 0, 50, 50 )
block.amplitude = 2
block.frequency = 10
vibrate1(block)
vibrateGroup:setReferencePoint(display.CenterReferencePoint)
vibrateGroup.x,vibrateGroup.y = x,y
return vibrateGroup
end
You can see the whole demo by grabbing SSKCorona and/or by downloading a binary onto your Android/Fire/Nook (sorry now iOS binaries).
[import]uid: 110228 topic_id: 32437 reply_id: 129000[/import]
Note: I pulsed the scale of the objects, but you could just as easily jiggle them left and right or up and down.
-Ed [import]uid: 110228 topic_id: 32437 reply_id: 129001[/import]
I was after position jiggling but I guess this will do as you said. Thanks very much
[import]uid: 99031 topic_id: 32437 reply_id: 129203[/import]
I was after position jiggling but I guess this will do as you said. Thanks very much
[import]uid: 99031 topic_id: 32437 reply_id: 129203[/import]