Hello,
I am trying to spawn an object based on the position of a user’s finger. The problem is, the object that is touched in order to spawn the object is controlled by the accelerometer. The object that is being spawned will also be controlled by the accelerometer. I’ve been working on this for 2 days and have had no luck. In previous projects, I used object.x = event.x and object.y = event.y to do this, but it doesn’t seem to be working. The error I am geeing is below:
Runtime error
/Users/username/Documents/Apps/Game/normal.lua:95: attempt to index global ‘event’ (a nil value)
stack traceback:
[C]: ?
/Users/username/Documents/Apps/Game/normal.lua:95: in function ‘spawnBlender’
/Users/username/Documents/Apps/Game/normal.lua:61: in function
?: in function <?:215>
[blockcode]function spawnBlender(event)
local blender = display.newImageRect (“images/blender.png”, 60, 67)
blender:setReferencePoint(display.CenterReferencePoint)
blender.x = event.x
blender.y = event.y
containerGroup:insert(blender)
blender.name = “blender”
physics.addBody(blender, “dynamic”)
blender:addEventListener(“touch”, removeBlender)[/blockcode]
Any help on this would appreciated. Is this even possible to accomplish?
Thank you.
[import]uid: 47722 topic_id: 18963 reply_id: 318963[/import]
[import]uid: 52491 topic_id: 18963 reply_id: 73049[/import]