Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
New Developer
badasschris
Posts: 15
Registered: ‎11-17-2010
My Device: Not Specified

Sample game code? (I ask too much)

Hello all,

 

I am very excited about the playbook and have ditched my attempts to create a android game and instead want to create it for the playbook. But I'm finding it very tricky to get a hold of any source code. Are there any samples about?

 

Also can someone give a rough outline of what I need to do to create a game my basic understanding is to have a update method and a draw method and just loop through them what I can't quite figure out is the basic layout. Is there any sample code that could help? maybe whenever a click event is detected an image is drawn there?

 

Sorry I'm being so vague this is all new to me (I know c# and the basics of java but not a lot else)

 

Thanks very much

Please use plain text.
Developer
Ebscer
Posts: 843
Registered: ‎08-31-2009
My Device: 9530, 9630, 9800, 8530, 9900, 9810, 9930, PlayBook, Dev Alpha
My Carrier: Verizon

Re: Sample game code? (I ask too much)

Unfortunately there is not much sample code available yet. However, so far I have found ActionScript to not be all that different from C# and Java.


Read my thoughts on BlackBerry Development at news.ebscer.com
Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Sample game code? (I ask too much)

I would not continuously loop since that will bottle neck the application and drive the CPU up.  Flex/AIR is an event driven system.  I would listen to frames and update the current state from that.  An Image can be listened to when a mouse click (or enter, leave, etc.) and you can then respond that mouse click event.

 

There are lots of tutorials on Flex/AIR and sample code out there.  Adobe AIR docs area at

 

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/package-detail.html

 

AIR also has built in effects to move, resize, etc (tweens) that can animate a lot of items as well that has better performance then moving an item on each frame.

Please use plain text.
Developer
fnicollet
Posts: 85
Registered: ‎10-25-2010
My Device: Not Specified

Re: Sample game code? (I ask too much)

Hi,

jtegen is right, an infinite loop is a bad solution when it comes to AS3. Use Event.ENTER_FRAME instead. To create as3 games, have a look at the kongregate video tutorials, they are well explained:

http://www.kongregate.com/labs

 

Hope this helps,

Fabien

Hope this helps,
Fabien

--
1. If you liked my post or found it useful please click on the white star and provide a Kudo!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!
Please use plain text.
New Developer
badasschris
Posts: 15
Registered: ‎11-17-2010
My Device: Not Specified

Re: Sample game code? (I ask too much)

Thank you all so much the links are perfect (you have been really really helpful) I'm at work now but I can't wait to get home and start coding something up. If I get anywhere I'll post back (more than likely with questions - sorry in advance)

Please use plain text.
Developer
fnicollet
Posts: 85
Registered: ‎10-25-2010
My Device: Not Specified

Re: Sample game code? (I ask too much)

Cheers for the kudos :smileyhappy:.

If it suits you well, you can mark this as Solved in the forum so that other readers can find it as well.

 

Fabien

Hope this helps,
Fabien

--
1. If you liked my post or found it useful please click on the white star and provide a Kudo!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!
Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Sample game code? (I ask too much)

You make also want to look at the Timer class.  It can send a callback to the milis-second level independent to the frame rate.  However, if the application is busy (or OS), and you are doing a lot of processing in between the timer duration (<10ms), you r application may stall momentarily at times.  It's a balance of updating the display (time needed), refresh rate, and user interactions.  Updating on frame rate can be done in conjunction with the Timer class, it all depends on what you are doing.  AS in not multi-threaded, so if you are trying to update 1000+ assets at one time, you may have to start using some coding tricks.

Please use plain text.
New Developer
badasschris
Posts: 15
Registered: ‎11-17-2010
My Device: Not Specified

Re: Sample game code? (I ask too much)

I also have another question. I saw a video of someone at adobe using the same code to run a AIR game on ipad/android pc etc. So does that mean if I make a app for the playbook with air it will be easy to port to the other platforms?

 

If I wanted to do this is there anything I need to keep in mind whilst making the app? and would these apps even be allowed on the respective markets (I thought android limited to java and iphone to objective c etc) Also I see no mention of windows phone 7 but that video at least made it look like once the code is done it's trivial to get it running on other devices.

 

One more question I'm poor and have downloaded adobe flash builder to make the apps (I think this is the only real solution) but if I can get an app finished within the 60 day trial can I release it? or do I need to pay for a licence?

 

Sorry loads of questions and really off topic but I thought better than posting a new topic.

Please use plain text.
Developer
fnicollet
Posts: 85
Registered: ‎10-25-2010
My Device: Not Specified

Re: Sample game code? (I ask too much)

Hey again,

Yes, your Adobe AIR application can run on ipad / android and pc, it's all about packaging the right think (apk, ipa, bar, air...).

So far, you have to use AIR 2.5 SDK for Android and BlackBerry (BB just adds come components to make it easier and platform coherent).

The packager for iOS is a bit behind (stil AIR 2.0) because Adobe stopped developping it for months ...

Here is a chart to compare the capabilities :

http://floatlearning.com/2010/10/key-differences-in-air-for-android-and-ios/

 

Here is a video i made that shows my application running on an Android 2.2 (HTC Desire) and on the BB Playbook simulator. I tried packaging on the ipad / iphone today and it worked (bit laggy because of what i said).

http://www.flex-tutorial.fr/2010/11/02/flex-et-composants-mobile-air-pour-android-ios-mon-approche/

Adobe didn't make any announce yet about W7 phones as it is all new.

 

If you can't afford a Flash Builder licence (standard is fine, don't bother with the pro licence), you can still copile using command lines but Flash Builder will save you plenty of time, it's worth the price really.

 

Fabien

Hope this helps,
Fabien

--
1. If you liked my post or found it useful please click on the white star and provide a Kudo!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!
Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Sample game code? (I ask too much)

In theory, if you are just using the SDK 4.5 (which is not supported for the playbook yet), and keep to the "spark" framework, and all your controls resize based on the platform it is running on, then probably yes.

 

However ( and there is always a however ), the playbook (PB) has its own SDK ontop of the Adobe AIR SDK for controls more suited for a multi-touch screen like the PB.  They will also have controls that are highly optimized for this multi-media device (video, audo, browsing, etc.)  This SDK will not be available or probably work on Android or other devices.  The PB is a device trying to get market share from Apple iPad, so it is targeting a different consumer than Android or even non-BB phones.  The PB will work with other BB phones, I doubt it will ever seamless work with non-BB phones (no business sense to do so since Android capable phones compete with BB phones).

 

The other however, is the real estate difference between the PB and the mobile phones.  The PB allows for a lot more room (not as much as the iPad), but a lot more than any phone.  So an application built for the PB should have more features than a similar application on a phone because you have more screen space, memory, CPU power, and diskspace.  Items that should be taken advantage of to give the end user a rich experience, one that they cant get on a cell phone.

 

New devices and OS always have the chicken-and-the-egg situation.  People dont buy hardware unless it has the applications to make their life more fullfilling (business, games, information, etc.).  Most software vendors will build applications for a new platform unless it has or will have a market share will give them some return on investiment.  Hence the reason why the 125+ deveopers on this list comes in and the give-away for a free PB by the release of the device.  However, if the quality is not there, Apple will have a field day on the small number and poor quality applications.  I am certain BB is working with some big names applications to make certain they are available upon release.

 

We too have a chicken-and-the-egg situation with the SDK and OS.  This is BETA software and there are features missing or not ready yet to make it possible to build those quality applications.  If we wait too long, it may be impossible to get the application done and accepted in time to receive the free PB.  I am personally working on about 6 applications that have different mesures of success with the current SDK and platform.  I hope 1 or 2 will converge in time with SDK updates and the product release.

 

Long winded answer.  In other words, build natively (AS/QNX/ETC) to take advantage of the hardware and give the consumer some WOW factor so the platform is a market success for BB so inturn it will be a continued market sucees for each of us.

Please use plain text.