Hi
I am using an older version of Android Extras but it working and serving my purpose...
Just looking for the basics on the controller adding for my game - it getting good reviews and I want to give a boost... :)
Hope you let people know what your game was made with!
If you want controller input via Android Extras, then you'll need to do something like this -
IF (Android.GameControllers("Up", 0)>600 OR Android.GameControllers("PadL_Up", 0)) THEN DEC y,10
IF (Android.GameControllers("Down", 0)>600 OR Android.GameControllers("PadL_Down", 0)) THEN INC y,10
IF (Android.GameControllers("Left", 0)>600 OR Android.GameControllers("PadL_Left", 0)) THEN DEC x,10
IF (Android.GameControllers("Right", 0)>600 OR Android.GameControllers("PadL_Right", 0)) THEN INC x,10
Make sure you use -
Android.GameControllers("Update")
- immediately before or after your SHOWSCREEN.
If you are using an old version of Android Extras, then remove the "Android." bits in the code.
Excellent, Thanks Guys.
I posted on a few retro game forums and shootemup websites and said the game was developed with GLBasic...will add a few developer diary like posts to my website too...
Android.GameControllers("PadL_Up", 0)) should been Android.GameControllers("PadL_Up", 0)>600. ALL input is between 0 and 1000. for digital inputs, its allways 0 or 1000. IM diddent do a 0 or 1, due unprecision from string to floats and that why im have detected analog and digital controllers in the Java code.
the 600 is just how much deadzone you will uses, but im fell 600 is quite good to uses as deadzone.
Also dont forget to uses the remapping feature, which is required for uses with normal Android. See Android Sample code for that. Im have shown a example for that.
Okay need to look at the remap thingy i think...
Also your instruction says to place gamecontrollers("update") after the showscreen ... is that so?
Would very useful to print out the details from the function ...
like so
PRINT ButtonRemapMessage$,0,450
QuoteAndroid.GameControllers("PadL_Up", 0)) should been Android.GameControllers("PadL_Up", 0)>600.
My code above is what I've used in my games (well without the INC/DEC... bits).
IIRC on OUYA and GameStick "PadL" is for the digital only DPad, so doesn't need a deadzone.
MrPlow:
GameController supports was originally designed for dedicated Androids Microconsol and do still need a little more work on the remap feature (like saving).
First at all you need do a this line somewhere in your init (or something like that) to set the gamecontroller layout, which is IMPORTANT for newer versions of AE:
Android.GameControllersSetLayout$("Left=Move Left;Right=Move Right;b1=shoot"
This is for the init part for the gamecontrollers and also for eventuelly remapping, what its needs to been remapped. Without its, the GameControllers wont work.
Then do a Android.Gamecontrollers("update") just before polling the first button or doing that just after AFTER SHOWSCREEN.
Then you just most to show ButtonRemapMessage$, if its got some content. Its also got two lines, which can uses SPLIT or StringField function.
All things was to been shown in the Android Sample project, and there have been some bugs in the eailer Android Extras remapping, so im wont supports the eailer versions here (its might or might not work).
Ian:
Did that work really? Im did have some trouble with that, and need to put on 1000 as im remember. This is for safe side, because digital buttons returns either 0 or 1000 from Java and im have not changed that when returned to glbasic. So im would not trust that. But you can do safe change >600 to =1000 if you wish.
IF you recommend using >600 then I'll do so in future, but my method is 100% successful on OUYA and GameStick for me - I can't say for general Android devices though as I don't have any.
Best to future-proof now though ;)
if its did work and reacted as its should, no problems to change that of course. Howover if you support remapping (see above), then im do recommend to uses >600 (or lower, if you want lower deadzone) on all buttons, except when doing real analoge controls of course.
Here is a more correct uses should have been this to avoid any confuction (can add to android gbas, which im add in the next version):
FUNCTION GamePoll#: Button$, PlayerID=1
LOCAL result$=Android.GameControllers(Button$, PlayerID-1)
LOCAL res=Result$
RETURN res/1000
ENDFUNCTION
PS. Im wansent aware of a boolean statement if check was FALSE = 0 and TRUE > 0. Normally its should have been FALSE = 0 and TRUE = 1 if you ask me.
Thanks Guys,
My head is mush after launching Viking Invaders on Playstore...mush I tells you!
I need some chill time 8)
I will tackle this controller issue tomorrow...