Page 1 of 3

Mobile Maze Application for on Android devices

Posted: Tue Mar 18, 2014 11:19 pm
by laurabar55
Hi, I was wondering if anybody could help me. I am making a maze mobile application for a college project. I am only making for now to work on android devices. I have all my mazes designed and in LiveCode, and I know how to make them work on desktop computers with on arrowkey commands.

But I need to get it working using accelerometer scripting. does anybody know where I can start?

Re: Mobile Maze Application for on Android devices

Posted: Wed Mar 19, 2014 12:14 am
by Simon
Hi laurabar55,
Welcome to the forum!

Here is the start;
http://lessons.runrev.com/s/lessons/m/4 ... al-compass
Now there is plenty in there you don't need but the basics are
mobileEnableAccelerometer
accelerationChanged X, Y, Z
Look both of those up in the dictionary.

If you get stuck just ask here.

Simon

Re: Mobile Maze Application for on Android devices

Posted: Tue Mar 25, 2014 3:29 am
by laurabar55
Hi,
I have some scripting that I want to test on an adroid device. However, when I go to save it as a standalone application, it pops up an error message that it could not compile the application class.

Does anybody know what this means?

Re: Mobile Maze Application for on Android devices

Posted: Tue Mar 25, 2014 3:51 am
by Simon

Re: Mobile Maze Application for on Android devices

Posted: Tue Mar 25, 2014 4:17 am
by laurabar55
"com.laurabar55.mazeapp"

I'm sorry but I have tried putting numerous things in that line, like what I have above. I don't exactly know what I am supposed to put in that section?

Re: Mobile Maze Application for on Android devices

Posted: Tue Mar 25, 2014 6:03 am
by Simon
Hi laurabar55,
Are you able to build and test a "Hello World" stack?

Simon

Re: Mobile Maze Application for on Android devices

Posted: Sat Mar 29, 2014 1:21 am
by laurabar55
Hi, I was working on my maze in Livecode and now the "edit pointer tool" is working the same as the "run browse tool".

Any ideas why? and how I can fix this? because I can't do any scripting, or editing of my mazes now.

Thanks,

Laura

Re: Mobile Maze Application for on Android devices

Posted: Sat Mar 29, 2014 5:00 am
by sefrojones
Laura,


Just a guess, but are you running livecode 6.6? Have you tried to compile your standalone in 6.5.2?

--sefro

Re: Mobile Maze Application for on Android devices

Posted: Sat Mar 29, 2014 5:35 am
by laurabar55
I think I clicked something that didn't allow me to make any changes. But luckily, I found a duplicate copy, that I just had to re-script a few things on. Thanks though.

Re: Mobile Maze Application for on Android devices

Posted: Sun Mar 30, 2014 5:33 pm
by laurabar55
Hi, Now that I have been able to test my maze on an Android tablet, I am having troubles getting the marble to move.
Can someone help me with this.

Here is the advice I was given already, but I can't get anything to work.

Here is the start;
http://lessons.runrev.com/s/lessons/m/4 ... al-compass
Now there is plenty in there you don't need but the basics are
mobileEnableAccelerometer
accelerationChanged X, Y, Z
Look both of those up in the dictionary.


my marble is called image "marble". and I want it to roll through the maze. how would I script it to do so?

thanks

Laura

Re: Mobile Maze Application for on Android devices

Posted: Sun Mar 30, 2014 11:19 pm
by Simon
Hi Laura,
With these two:
mobileEnableAccelerometer
accelerationChanged X, Y, Z
Can you see that x,y,z will change as you move the device?

Start a new stack with just 3 fields on a card.
in the card script:

Code: Select all

on openCard
   if the environment <> "mobile" then exit openCard
   get mobileSensorAvailable("acceleration")
   if it is false then
      answer "Sensor unavailable"
      exit openCard
   end if
   mobileEnableAccelerometer 1000
end openCard

on accelerationChanged pXAccel, pYAccel, pZAccel
   put round(pXAccel,2) into fld 1
   put round(pYAccel,2) into fld 2
   put round(pZAccel,2) into fld 3
end accelerationChanged

on closeCard
   mobileDisableAccelerometer
end closeCard
I rounded the values because it looks crazy if you don't, but you can take that off.

From there can you see how to set the location of the marble?

Simon
Edit; oops made a boo boo

Code: Select all

on closeCard
if the environment = "mobile" then
   mobileDisableAccelerometer
end if
end closeCard
Better

Re: Mobile Maze Application for on Android devices

Posted: Mon Mar 31, 2014 1:22 am
by laurabar55
Hi thank you so so much for your help

on openCard
set location of image "marble" to 675,167
set the visible of image "instructions2" to false
set the visible of image "close2" to false
   if the environment <> "mobile" then exit openCard
   get mobileSensorAvailable("acceleration")
   if it is false then
      answer "Sensor unavailable"
      exit openCard
   end if
   mobileEnableAccelerometer 1000
end openCard

on accelerationChanged pXAccel, pYAccel, pZAccel
   put round(pXAccel,2) into fld 1
   put round(pYAccel,2) into fld 2
   put round(pZAccel,2) into fld 3
end accelerationChanged

on closeCard
if the environment = "mobile" then
   mobileDisableAccelerometer
end if
end closeCard



that is the code that I have on my maze now, but I am stuck on how to get my image "marble to roll through the maze? I have tried numerous things, and all I have accomplished is getting to move on touch through the maze (this is my backup plan for handing in my assignment). But, I really want it to roll through the maze using accelerometer scripting.

thanks for all your help,

Laura

Re: Mobile Maze Application for on Android devices

Posted: Mon Mar 31, 2014 1:38 am
by Simon
Hi Laura,
I understand what you would like to do.
But you haven't added any scripting to move the marble.

I can see you know how to set the location of the marble so how would you implement the x,y from the accelerationChanged message?
If you have the 3 fields you can see that the numbers change as you tilt the device.

Simon

Re: Mobile Maze Application for on Android devices

Posted: Mon Mar 31, 2014 2:00 am
by laurabar55
Hi, ok, so I put those fields in there and yes the numbers in the boxes changes as I move the device.

would I do something like this?

on accelerationChanged pXAccel, pYAccel, pZAccel
move image "marble"(pXAccel,2)
move image "marble"(pYAccel,2)
move image "marble"(pZAccel,2)
   put round(pXAccel,2) into fld 1
   put round(pYAccel,2) into fld 2
   put round(pZAccel,2) into fld 3
end accelerationChanged


I know the move keyword is wrong because it is coming up with an error code.

thanks,

Laura

Re: Mobile Maze Application for on Android devices

Posted: Mon Mar 31, 2014 2:47 am
by Simon
You are getting closer but
move image "marble"(pXAccel,2)
that comma 2 is for the round function only.

Again...
you know how to set the location
.... hint hint hint

If I'm being just a pain say so, I'd like you to solve this because it will make you much happier.

While I'm saying you are close you still have a lot of work to do, it's not as simple as just using accelerationChanged. You have looked at the numbers coming back from that message?

Simon