Flixel Forums

development => iOS => Topic started by: knarrenheinz on Sun, Jun 12, 2011

Title: flixel + AIR SDK 2.6
Post by: knarrenheinz on Sun, Jun 12, 2011
Greetings,

I packaged an old flixel game (v1.5x) for iOS/Android with the AIR SDK 2.6 and would love to hear how it runs on your devices. You can get the free versions here:

Little Robo Run (iOS) (http://itunes.apple.com/us/app/little-robo-run-free/id441926718?mt=8)
Little Robo Run (Android) (https://market.android.com/details?id=air.de.codinsoft.littleRoboRunFree)

I mainly just needed to throw in multitouch controls and adjust the screen size. It runs @ 25-30 fps on an iPod 3rd gen. Can't wait for AIR SDK 2.7...

Thanks :)
heinz
Title: Re: flixel + AIR SDK 2.6
Post by: 3WG on Sun, Jun 12, 2011
Great .

I liked the flash version it will feed my ipad and galaxy tab :)

Do you have any tutorial for mutlitouch ?

Did you use FlashDevelop or Flash Builder ?
Title: Re: flixel + AIR SDK 2.6
Post by: knarrenheinz on Mon, Jun 13, 2011
Hey 3WG,

there are two very good multitouch tutorials from Adobe:

First (http://www.adobe.com/devnet/flash/articles/multitouch_gestures.html) (by Christian Cantrell)
Second (http://mochiland.com/articles/virtual-controllers-for-touch-based-devices-pt-1) (by Mike Jones)

I used FlashDevelop for progamming and Flash CS5 for packaging.
Here (http://priyeshsheth.wordpress.com/2011/03/25/adobe-air-2-6-with-flash-cs5/) is a little tut about integrating AIR 2.6 into CS5.

Hope this helps :)
Title: Re: flixel + AIR SDK 2.6
Post by: 3WG on Tue, Jun 14, 2011
Thanks for the tutorial links.

Another question : How did you make for packaging it with flash IDE ?

I just buyed flash CS5.5 and i'm very impatient to test one of my game on my Galaxy TAB .

Title: Re: flixel + AIR SDK 2.6
Post by: knarrenheinz on Tue, Jun 14, 2011
Hey 3WG,

here's what could work within CS5.5 (I used CS5 and had to package the game via commandline):

1. Create a new "AIR for Android" project within CS5.5
2. Make your flixelgame sourcefiles available for the project (i.e. copy your sourcefiles into the project folder or set a new source path)
3. Set your old main class as Document class (do not use the preloader)
4. Open up "Publish Settings -> AIR for Android" and set stuff like aspect ratio, app name, icons, certificates etc. (you can create a self-signed cert. from within CS5.5)
5. Compile/Deploy the game

It could be that flash IDE asks you for the location of the FlexSDK... just set the path then :)

Cheers (hopefully)
Title: Re: flixel + AIR SDK 2.6
Post by: 3WG on Tue, Jun 14, 2011
Thanks a lot ..

Where you from exactly in germany

I'm from Luxembourg we are neighbor :)
Title: Re: flixel + AIR SDK 2.6
Post by: willcrain on Wed, Aug 24, 2011
Hey knarrenheinz,
Thanks for sharing. I am newer to flixel and trying to explore it with the AIR platform also. I saw that you suggested some TouchMode tutorials. I have been able to use Touch Gestures before, but am not able to get my FlxSprite to listen for them?

for example:
myFlxSprite.addEventListener(TouchEvent.TOUCH_BEGIN, onTouchBegin);

From what i have come to understand all of the flixel objects are blitted onto the page, so how do you addEventListeners to them? or are you overlaying buttons on top of the game layer?

Did you track your 'mouse position' and then adjust actions to that with the overlap method?

For instance, if i wanted to create a custom graphic button to be pressed. --> overlap method?
Or, if i wanted to create a sprite to be dragged across the screen with my finger --> overlap method?

I guess i am just trying to see where you used the TouchEvents in your app.

Sorry if this seems confusing. Any tips would be appreciated.
Title: Re: flixel + AIR SDK 2.6
Post by: felipe on Thu, Aug 25, 2011
@willcrain

I have worked with touch events and flixel on an ipad, playbook and android phones and what I've use in all cases is a virtual d-pad, if it's the case you want to control a sprite.

What I've used to interact with touch event on flxsprites inside the game is drawing a rectangle sprite over it and just adding the event listener to the sprite.
I haven't really noticed a big performance problem with this method.

I've also tried adding the event listener to the stage and just comparing the flxsprite point to the touch point.
Title: Re: flixel + AIR SDK 2.6
Post by: willcrain on Thu, Aug 25, 2011
@felipe

Thanks for the reply.

I am trying to drag a sprite across the screen and still having some issues.

I tried drawing a simple rectangle shape and also played with the idea of relaying the touch coordinates. My issues are that I am not able to an addEventListener to anything within the Flixel world. I have tried adding a listener to the stage, the rectangle that i was trying to track by touch/mouse coordinates and the flxSprite itself. None with any success due to that i cant add event Listeners.

I am playing with templates from the Flixel Power Tools collection as a reference

the following is a mess, i know, but you can get an idea, hopefully of what i am trying. Thanks again for any help you might have to give.
something i have tried:

Code: [Select]
import flash.display.*;
import flash.events.TouchEvent;
import flash.ui.Multitouch;
import flash.ui.MultitouchInputMode;

private static var tPos:Object;
private static var xPos:Number;
private static var yPos:Number;

public var touchBOOL:Boolean;


Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
/// the following 3 lines don't work because it doesn't know
// what the addEventListener method is
addEventListener( TouchEvent.TOUCH_BEGIN, onTouchBegin );
addEventListener( TouchEvent.TOUCH_MOVE, onTouchMove );
addEventListener( TouchEvent.TOUCH_END, onTouchEnd );

player = new FlxExtendedSprite(64, 64, imagePNG);
player.solid = true;
player.allowCollisions = FlxObject.ANY;
// mouseDrag doesn't work on touch devices, disabled for now?
// player.enableMouseDrag(false, true); 

_rect = new FlxSprite(player.x, player.y);

/// this doesn't work because it doesn't know what the addEventListener method is
// _rect.addEventListener( TouchEvent.TOUCH_MOVE, trackerMove ); 

add(player);
add(_rect);


override public function update():void
{
super.update();
// updates the position of _rec to match the mouse/Touch

// _rect.x = FlxG.mouse.x - (_rect.width/2);
// _rect.y = FlxG.mouse.y - (_rect.height/2);

// if (FlxG.collide(player, _rect)) {
//
// }

}

public function onTouchBegin(evnt:TouchEvent):void
{
touchBOOL = true;
}
private function onTouchMove(evnt:TouchEvent):void
{
if (touchBOOL) {
xPos = evnt.stageX;
yPos = evnt.stageY;
}
}
private function onTouchEnd(evnt:TouchEvent):void
{
touchBOOL = false;
}
public function getCoords():Object
{
tPos.x = xPos;
tPos.y = yPos;
return tPos;
}