Flexible Gaming: Using Canvas Versus UIComponent?

For developing simple games with the Flex SDK, what are the implications of using a Canvas versus a UIComponent as a drawing surface? Are there any performance issues? Are the methods generally the same? Searching around, it seems that most of the code examples I have found use UIComponent. Is this common or is there a reason?

I already know one strange difference - I developed a simple Pong game using:

    public class MyGameCanvas extends UIComponent

      

and then decided to replace UIComponent with Canvas. This caused the line to fail:

addChild(paddle);

      

After spending too many hours searching, I finally found that the Canvas object requires:

rawChildren.addChild(paddle);

      

due to the chain of inheritance of objects, Sprites above Canvas.

But it doesn't seem like preferring one class over the other. Are there any specific reasons? Thank.

Update: Ok, I'm assuming Canvas is missing and UIComponent is enabled. The only reason I even tried the Canvas object is for the name. I mean this Canvas is not where you should be doing drawing? :)

So the second question that came up was about using the Flex SDK (and I don't know if this should be a completely new question, or if it's okay here).

However, I have to confirm something by being new to Flex and different terminology. I'm guessing people mean I shouldn't use MXML for games when they said Flex SDK. As I thought the Flex SDK was what the compiler provided that generates the .swf files. Otherwise, where / how could I compile AS3?

Assuming that is the case, then my question would be about the usability of both MXML and AS3 for (simple) games. Based on what I read about both, it seemed like their use was MXML for UI elements, and AS3 for everything else. Is the overhead bad for MXML?

John C>

+2


source to share


3 answers


The canvas has a bunch of extra layout code plus scrollbars. It is definitely heavier than UIComponent. Also, it's important to know that Canvas requires all children to be subclasses of UIComponent. Using rawChildren to add a non-UIComponent is a hack if you don't create some kind of chrome for the Flex container (scrollbars on the canvas and border / background in the panel).



I agree with PeZ. Flex's structure is probably not playable. If you don't have a game interface with things like DataGrids, Trees, Charts, etc., you can get a smaller and optimized SWF without Flex.

+2


source


I think there is no point in using flex sdk for game development. The Flex SDK was designed with application development in mind, so you shouldn't use it to create games.



Do you have specific reasons to use it instead of a simple AS3 project?

+3


source


If you do not need additional materials on the canvas, such as scrollbars, this is clearly a reason for preferring UIComponent. The canvas is simply a heavier object.

0


source







All Articles