Hi,
I have an existing Corona SDK app and it works great. I am trying to port it to CoronaCards for Phonegap. I am facing two issues
-
The height and width of the CoronaView is not being properly set (most likely 'coz I am doing something wrong). I get the height and width using $window.screen.innerHeight/Width (am using ionic) and pass it to CoronoView, but it appears to be too small. I kinda resolved it by using a scaling factor to get the desired height and width (will not work on various devices), but since this is so basic, I guess I must be doing something wrong. Any pointers would be appreciated.
-
How do I send events from my Lua to Javascript ? I(btw, see a sendEvent in CoronaCards phonegap plugin send from Javascript to Lua which is great). My use case is that when a user finishes a level, I want to send an event to my ionic app to do something. Is it possible ?
Thanks in advance for your help !
Hi,
I have since verified that the sendEvent from my JS to Lua works. Any pointers on how I can send events from Lua to JS would be greatly appreciated.
Thanks,
Guys,
Sorry to be a pest about this. I would greatly appreciate some help here. I am evaluating the CoronaCards trial license to see if I can make things work and upgrade to a full license.
Looks like we don’t have a setCoronaEventListener exposed in the PhoneGap api. I tried the native Android Corona Cards and still cant receive messages from Lua to Android. Here is the test code
main.lua
========
[lua]
print "Corona - in create scene … "
local eventToJS = { name=“corona2js”, message=“Hello from CoronaCards!” }
local result = Runtime:dispatchEvent( eventToJS )
print "Corona - after event dispatch . "
[/lua]
MainActivity.java
=========
CoronaView cv = (CoronaView) findViewById(R.id.cv);
cv.setCoronaEventListener(new CoronaEventListener() {
@Override
public Object onReceivedCoronaEvent(CoronaView arg0,
Hashtable<Object, Object> arg1) {
Log.d(“Corona”, arg1.get(“message”).toString());
return “Nice to meet you CoronaCards!”;
}
});
Any pointers will be appreciated. If communication is under dev, please let me know so that I don’t spend any more time on this. Also, if the PhoneGap CordonaCards plugin is no longer supported, please let me know as well.
Thanks much for your help
Update - Just in case anybody else is also searching for this - the plugin API does not expose setEventListener (atleast in the version publicly available) - so it is unlikely that events from Lua to JavaScript are supported in the PhoneGap plugin. Events from Lua to Java in native android work fantastic though.
Hi,
I have since verified that the sendEvent from my JS to Lua works. Any pointers on how I can send events from Lua to JS would be greatly appreciated.
Thanks,
Guys,
Sorry to be a pest about this. I would greatly appreciate some help here. I am evaluating the CoronaCards trial license to see if I can make things work and upgrade to a full license.
Looks like we don’t have a setCoronaEventListener exposed in the PhoneGap api. I tried the native Android Corona Cards and still cant receive messages from Lua to Android. Here is the test code
main.lua
========
[lua]
print "Corona - in create scene … "
local eventToJS = { name=“corona2js”, message=“Hello from CoronaCards!” }
local result = Runtime:dispatchEvent( eventToJS )
print "Corona - after event dispatch . "
[/lua]
MainActivity.java
=========
CoronaView cv = (CoronaView) findViewById(R.id.cv);
cv.setCoronaEventListener(new CoronaEventListener() {
@Override
public Object onReceivedCoronaEvent(CoronaView arg0,
Hashtable<Object, Object> arg1) {
Log.d(“Corona”, arg1.get(“message”).toString());
return “Nice to meet you CoronaCards!”;
}
});
Any pointers will be appreciated. If communication is under dev, please let me know so that I don’t spend any more time on this. Also, if the PhoneGap CordonaCards plugin is no longer supported, please let me know as well.
Thanks much for your help
Update - Just in case anybody else is also searching for this - the plugin API does not expose setEventListener (atleast in the version publicly available) - so it is unlikely that events from Lua to JavaScript are supported in the PhoneGap plugin. Events from Lua to Java in native android work fantastic though.