first time poster!
I have a question regarding Containers in Corona and was hoping someone would be able to help out!
I am developing a game in which I have several display objects (Images) that respond to user touch via touch listeners. It works great, the only issue is that I would like to increase the area in which the touch listener responds, making it greater than the bounds of the image.
I figured I would do this with containers, making a separate container for each image with bounds exceeding those of the image, please see the below code for clarification.
First I initialize both the image display object and its associated container, notice that I increase the bounds when creating the container:
[lua]self.image = display.newImageRect(image, width, height) --this is the display object that will appear on screen
self.container = display.newContainer( level_parent:get_group(), width + 100, height + 100 ) --create container to extend accuracy of bounds
I then add the necessary touch listener to the container:
[lua]self.container:addEventListener(“touch”, touchListener) – touch event listeners[/lua]
Here is the external code which calls this creation, as well as inserting the image as a child of the container and setting the necessary transforms:
[lua]block_obj = block.new(level_init, image, data[i][j], x, y,theta, i, j, r, rotation, is_block, width, height) – create new block object
block_container = block_obj:get_container()
block_image = block_obj:get_image()
block_container.x = x; block_container.y = y
block_container.rotation = rotation
When I run the code, these changes are not reflected; the user touch still only works within the bounds of the display image.
Thank you for any information you can provide.