Posted on by

It’s Wednesday and time for another frequently asked questions (FAQs) session. Today we answer some FAQs related to Graphics 2.0.

1. Will my existing code run with Graphics 2.0?

Graphics 2.0 has a new redesigned graphics engine with lots of new features. To help you get started with your existing code, we added a Graphics 1.0 (V1) compatibility mode. You set the V1 flag in the config.lua of your project.


application =
{
   content =
   {
      graphicsCompatibility = 1,  -- Enable V1 Compatibility mode
      width = 320,
      height = 480,
      scale = "letterbox"
   },
}

When this flag is set, the Graphics 2.0 API is 99% compatible with Graphics 1.0.

2. Can I use the new Graphics 2.0 features while in V1 compatibility mode?

We don’t restrict the new Graphics 2.0 APIs but we don’t recommend mixing the new with the old. The intent for the compatibility mode is to be able to test your existing code with the Graphics 2.0 engine before converting it to the full Graphics 2.0 features. It can also be confusing mixing new APIs with the old. In V1 mode, the existing Display Objects uses Top/Left anchor points when the object is created, but if you create a Graphics 2.0 Display Object (e.g., display.newPolygon), it uses x/y (center) anchor points.

3. What changes do I need to make to my code to run in the full Graphics 2.0 mode?

The following is a list of things you will need to change when you run your project in full Graphics 2.0 mode (when graphicsCompatibility is not included in your config.lua file).

  • Display Objects are created with X/Y (center) positioning instead of Top Left.
  • display.setReferencePoint has been removed. Use object.anchorX and object.anchorY instead.
  • display.newGradient has been deprecated. Use object.fill = table instead.
  • All RGBA color values have changed from 0:255 to 0:1. You can convert existing color values by dividing the old values by 255.
  • object:setTextColor has been deprecated. Use object:setFillColor or object.fill = value instead.
  • line:setColor has been deprecated. Use line:setStrokeColor instead.
  • line.width has been deprecated. Use line.strokeWidth instead.
  • xReference, yReference, xOrigin and yOrigin have been removed. Use anchorX and anchorY instead.
  • Groups don’t have anchor points enabled by default. You need to set “group.anchorChildren = true” to enable anchor points on the group.

4. Will V1 compatibility mode be supported forever?

V1 mode is meant to be a transition to full Graphics 2.0 and at some point will be removed from the Graphics 2.0 build.

5. Where can I find more information about Graphics 2.0?

Graphics 2.0 is in Beta and available to Corona SDK Pro and Enterprise users. You can find out more information and download a daily build here.

If you want to install the Graphics 2.0 build along side your existing Corona SDK build, please follow these instructions: for Mac users, rename the existing Corona SDK folder to something different so the Graphics 2.0 build doesn’t overwrite the existing SDK. (I add the build number to the end of the CoronaSDK name.) For Windows users, the Graphics 2.0 build is named: Corona Simulator – Graphics 2.0 Beta, so nothing needs to be done to install it along with the standard Corona SDK.

It should be noted that the Graphics 2.0 Corona SDK is a work in progress and not all the sample projects and documentation has been updated to match the product. That will be changing soon.

We encourage you to try Graphics 2.0 and report any bugs you find using our bug reporting system. You can also provide feedback in our Graphics 2.0 forum. Be sure to check out the known issues page before reporting any bugs.

That’s it for today’s questions. I hope you enjoyed them and even learned a few things.


Posted by . Thanks for reading...

9 Responses to “Wednesday FAQs: Graphics 2.0”

  1. Thomas

    Hmmmm. I can understand some stuff (like the anchor points from 0 to 1), but color values should really be in 8-bit format for it to be practical…

    Reply
  2. Cleverson

    Hi,

    Great FAQ! I’m very inclined to make the change to Graphics 2.0.
    One question though. How is the performance of G2.0 compared to 1.0? If I just use standard things like groups, display objects, transitions and so on, will my game get a better performance on 2.0?

    Reply

Leave a Reply

  • (Will Not Be Published)