Originally posted in UI forum believe it would be better here:
I have only been using Corona for a couple of weeks and love it. However I have reached a full stop on my project due to my limited understanding of how to access the contents of tables and run functions created using modules.
I have put a project which illustrates the core issues I am having here:
https://github.com/michael45/animated_sprite_test
The project is based on a hacked up version of one of the Spriteloq demos (http://www.loqheart.com/spriteloq/) I hope they don’t mind.
The project has two animated characters. the one on the left is created locally so I have no problems accessing functions such as prepare(), play() or the curSprite table. A function onTouch cycles through the spriteNames as per the demo when the local sprite on the left is clicked.
The sprite on the right is created using a separate module Enemy.lua my intention is to put all the code associated with AI for the enemy in this file and keep the main file clean. I will be using director.lua to control transitions but this example is intended to focus on the core issues which are:
-
How do I get access to the sprite functions for the animated character on the right. I have printed tables for the enemy object in the project but can’t work out how to set up a listener and function which will change the right figure in the same way as the local left hand figure does.
-
In the real main project the right hand figure is a 3D animated character which I would like to automatically select the appropriate animation sequence depending on its direction. This would ideally be done automatically within the Enemy.lua, I have written some code which selects the sequence based on direction but how can I make the animation change sequence from within the Enemy.lua.
Any help or comments would be appreciated and hopefully once I get up to speed I will be able to return the favour to others.
Michael45
bit of a crappy handle will change when I get a chance 
[import]uid: 82298 topic_id: 14967 reply_id: 314967[/import]