Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Issues with graphicsCompatibility = 1
Started by beernathan May 07 2014 08:46 PM

- - - - -
30 replies to this topic

Best Answer Rob Miracle , 03 August 2014 - 05:42 PM

That's what it would appear to be.   G2 is working as it supposed to.

 

Rob

[TOPIC CONTROLS]
Page 1 of 2 1 2
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

beernathan

[GLOBAL: userInfoPane.html]
beernathan
  • Contributor

  • 357 posts
  • Corona SDK

I'm having a problem running my graphics 1.0 code in graphics 2.0 with compatibility mode switched on.

 

Here's my config.lua

 

application = {
content = {
                graphicsCompatibility = 1,  -- Turn on V1 Compatibility Mode
                width = 320,
height = 480, 
scale = "letterbox", 
fps = 30,

        imageSuffix = {
    ["@2x"] = 1.5,
                    ["@4x"] = 3, -- for iPad 3
}

},
}

I'm running 2189 - when I run without the compatibility flag it's all over the place.

 

Here's one object that works just fine:

myMenuObject.MenuMessageDialog.HeadingTxt = display.newText(myMenuObject.MenuMessageDialog.Group, "Heading", 0, 0, font.bold, 16)
myMenuObject.MenuMessageDialog.HeadingTxt.x = 100
myMenuObject.MenuMessageDialog.HeadingTxt.y = 100It over-rides the original x,y at object creation with a new x & y which were always relative to the middle of the object.

Here's one that doesn't work (appears in the wrong position):

local textOptions = { parent = myMenuObject.MenuMessageDialog.Group, text = "", x = 100, y = 100, width = 200, height = 100, align = "center", font = font.normal, fontSize = 14}
myMenuObject.MenuMessageDialog.MessageTxt = display.newText(textOptions)

Note that this method of text creation which allows alignment has always been relative to the centre of the object on creation - perhaps compatibility doesn't take this into account?

 

Also buttons don't work if their alpha is zero ("myMenuObject.MenuMessageDialog.ButtonOK:setFillColor(217,217,217,0)") which was fine before.

 

These were just the things I noticed on my first screen - wanted to make sure I wasn't missing something obvious before I took a deeper dive.

 

Nathan.

 



[TOPIC: post.html]
#2

beernathan

[GLOBAL: userInfoPane.html]
beernathan
  • Contributor

  • 357 posts
  • Corona SDK

Hi @Rob - any chance you can take a look at this?

 

Thanks,
Nathan.



[TOPIC: post.html]
#3

beernathan

[GLOBAL: userInfoPane.html]
beernathan
  • Contributor

  • 357 posts
  • Corona SDK

Hello????



[TOPIC: post.html]
#4

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,922 posts
  • Enterprise

Run this block of code:

local block = display.newRect(100,100,200,100)
block:setFillColor(1,0,0,0.5)

local textOptions = {
     text = "somestring",
     x = 100,
     y = 100,
     width = 200,
     height = 100,
     align = "center",
     font = native.systemFont,
     fontSize = 14}
mytext = display.newText(textOptions)
mytext:setFillColor(1)

local dot = display.newCircle(100,100,4)
dot:setFillColor(0,0,1)

 

What I'm doing is drawing a 200x100 rectangle centered on 100,100, which is what your second form of display.newText() is doing.  I also draw a dot at 100,100 to show you where the center of the block is.

 

In your first display.newText() you're not specifying a width or height, so the image returned by the function is a tight fit to the actual text.  If your string ends up being 50px wide and 20px high, then that 50x20 box will be centered on 100,100.  But in your second form,  you're saying fit the text to a 200x100 box.  The text will wrap when it gets wider than 200px and be centered horizontally in the box, however, it starts from the top of the box as the sample above shows.  If you want it vertically centered, then specify a height of 0.  If not we are going to give you what you asked for.

 

Rob



[TOPIC: post.html]
#5

beernathan

[GLOBAL: userInfoPane.html]
beernathan
  • Contributor

  • 357 posts
  • Corona SDK

Hi Rob,

 

I don't doubt that your code will work - what I'm saying is that my second example behaves completely differently on graphics 1.0, to what it does on graphics 2.0 with compatibility mode turned on.

 

The text wrapping and alignment is fine - it's the positioning of the text that has changed.

 

I adjusted your code a little to get the colours to light up...

 

local block = display.newRect(100,100,200,100)
block:setFillColor(100,100,100,150)


local textOptions = {
     text = "somestring",
     x = 100,
     y = 100,
     width = 200,
     height = 100,
     align = "center",
     font = native.systemFont,
     fontSize = 14}
local mytext = display.newText(textOptions)
--mytext:setFillColor(1)


local dot = display.newCircle(100,100,4)
dot:setFillColor(255,0,0)

 

 

Here is the output when running on 1262 (graphics 1.0):

 corona_1262.png

 

 

Here is the output when running on 2189 (graphics 2.0) with no compatibility - which I don't expect to work:

corona_2189_no_compat.png

 

Here is the output running on 2189 (graphics 2.0) with compatibility turned on:

corona_2189_compat.png

 

As you can see the final output looks nothing like the graphics 1.0 output???

 

Nathan. 



[TOPIC: post.html]
#6

davidcondolora

[GLOBAL: userInfoPane.html]
davidcondolora
  • Contributor

  • 171 posts
  • Corona SDK

@beernathan: Any luck on any of this? Due to the IDFA issue I too am likely going to have to update my game to Graphics 2.0, and the compatibility mode leaves much to be desired. All of the transitions happening (Graphics 2.0, Composer) around the release of my game have left me frustrated with Corona.



[TOPIC: post.html]
#7

beernathan

[GLOBAL: userInfoPane.html]
beernathan
  • Contributor

  • 357 posts
  • Corona SDK

Hi @davidcondolora,

 

Frustrating for me too - no reply from @Rob-Mircale. feel like I can't progress without some direction here as Corona is not behaving as per the documentation.



[TOPIC: post.html]
#8

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,922 posts
  • Enterprise

I'm confused about why with Graphics 1.0, your text block is drawing where it is.

 

If you use the old style text creator:  local mytext = display.newText("somestring", 100, 100, 200, 100, native.systemFont, 14)

 

Then there is no difference between G1 and G2 in graphics compatibility mode.  But when I use the display.newText() in the new way, it's not drawing in the right place with your G1 method.  The red dot represents 100, 100 on your screen.   The display.newText() you are telling to draw it's top left corner at 100, 100, which under G1 it is not.  It's centering the block on the X axis.  I don't know why the Y axis is drawing as high on the screen as it is.  It's almost like it's got a :setReferencePoint() on it or it's like the display.newText() in the new mode is behaving like it should in G2 mode.

 

I would say the G1 version with the new style is a bug.  The way it should work in G1 and G2 with compatibility mode is that you should get a 200x100 box.  The text should be centered in that box and then the top left should be at 100, 100. 

 

In G2 without compatibility mode, that block should be centered at 100, 100.  Which is what looks like is happening in G1 builds.



[TOPIC: post.html]
#9

beernathan

[GLOBAL: userInfoPane.html]
beernathan
  • Contributor

  • 357 posts
  • Corona SDK

Hmmmmm. OK thanks @Rob-Miracle - so if I read your comment right, you're saying G1 with the new style had a bug in it, and that G2 with compatibility isn't compatible with that G1 bug ;-)

 

I'm happy that at least i know that - it's a much more solid foundation for me to move forward on, as I can update my "new style" calls across the board to make them compatible with "G2 compatibility mode". At least then I can move onto a current release before I make the big jump to G2.



[TOPIC: post.html]
#10

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,922 posts
  • Enterprise

  Best Answer

That's what it would appear to be.   G2 is working as it supposed to.

 

Rob



[TOPIC: post.html]
#11

lbolduc

[GLOBAL: userInfoPane.html]
lbolduc
  • Enthusiast

  • 83 posts
  • Corona SDK

@Rob, I'm running graphicsCompatibility = 1 now, and trying to transition to 2.0. I think the only offending thing that I'm using is setReferencePoint. All of my objects are center referenced like this:

 


local label = display.newImageRect("images/label.png", 100,100);
label:setReferencePoint(display.CenterReferencePoint);
label.x = 646; label.y = 706;
label.scene = "label";

 

Based on what I'm reading, it looks like all I need to do is remove the setReferencePoint line of code for each object. Is that right?



[TOPIC: post.html]
#12

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,922 posts
  • Enterprise

That should take care of it.  We also dropped out the legacy sprite library with the Graphics 2.0 build.  If you need it, you can download ti from github and just drop it in your folder and won't miss a beat.

 

Rob



[TOPIC: post.html]
#13

lbolduc

[GLOBAL: userInfoPane.html]
lbolduc
  • Enthusiast

  • 83 posts
  • Corona SDK

@Rob,

 

Thanks very much. Mostly ok, but several Problems

 

Currrent stand out ... 

 

Corona staff have consistently recommended that I create a series of rectangular, hand-coded, overlay objects to distinguish user touches on irregular-shaped juxtaposed objects. The 50 visible objects were center referenced; they're fine. The 'alpha = 0.01' overlays were upper-left xy referenced. All 100+ have shifted out of place.

 

I'll include sample code for one overlay. Tried to include a pic but can't find the accepted file format.

 

Do you you know of any search-and-replace-based syntax assignment to easily readjust their new centered location to their former upper left xy location? Or, worst case, can you recommend a clever algorithm to recalculate the values?

 

me_shape_1 = display.newRect( 835, 100, 57, 60 );
me_shape_1.alpha = .01;
me_shape_1.order = 1;
me_shape_1.match = me;
me_shape_1.isMask = true;

 

Thanks.



[TOPIC: post.html]
#14

davidcondolora

[GLOBAL: userInfoPane.html]
davidcondolora
  • Contributor

  • 171 posts
  • Corona SDK

@Ibolduc: I just went through the same ordeal. Anywhere you use display.newRect, if you expect it to be Top-Left aligned, you'll need to manually anchor it to top left. My recommendation is to include this line after you create the object:

me_shape_1.anchorX = 0; me_shape_1.anchorY = 0

Positioning should work as expected from here, now that it has a top-left anchor point.



[TOPIC: post.html]
#15

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,587 posts
  • Corona SDK

@lbolduc,

 

I noticed you mentioning using alpha 0.01 for your your overlay (invisible) touch objects.  

 

My assumption is you want the overlay to act as a touch object but to not be visible to the user.

 

Might I suggest one of two better options?

 

1.  Use a fully transparent (alpha == 0) rectantgle and set the isHitTestable attribute to true.  Why?  In my experience, previously using your technique over several devices, I found that sometimes low alphas got treated like zero alpha and thus no touch was recorded.  Also, sometimes even low alphas are visible, thus creating ugly artifacts.

 

 

2. Use an imageRect and fill with a fully transparent texture.  I use this solution exclusively now.  In fact, all my projects keep two textures:

  • fillT.png - 16x16 Transparent fill texture.
  • fillW.png - 16x16 White fill texture.

When prototyping and debugging I use fillW.png for my (later to be invisible) touch objects/helpers so I can see them, position them, and verify their placement.  I may set the alpha to 0.5 and colorize them too based on my debugging situation.  

 

Then, after I'm satisfied, I change the fill texture to fillT.png and bingo, an invisible touch object that always works.

 

 

I hope this helps.


Edited by roaminggamer, 14 August 2014 - 08:18 AM.


[TOPIC: post.html]
#16

davidcondolora

[GLOBAL: userInfoPane.html]
davidcondolora
  • Contributor

  • 171 posts
  • Corona SDK

@lbolduc and @roaminggamer: On that same idea, anytime I use invisible objects that I attach touch events to, I toggle invisibility to false and hit testability to true:

newObject = display.newRect(0, 0, 1024, 768)
newObject.isVisible = false
newObject.isHitTestable = true

My guess is that this is 'cheaper' from a processing standpoint, as no alpha operations are involved.



[TOPIC: post.html]
#17

lbolduc

[GLOBAL: userInfoPane.html]
lbolduc
  • Enthusiast

  • 83 posts
  • Corona SDK

@davidcondolora and @roaminggamer, thanks very much for your invisible object suggestions. I'll check those out. 

 

@davidcondolora, re: anchorX/Y ... WOW! That's a beautiful sight :) All realigned and relatively painless. Thanks so much!

 

Only 2 mod-tranistion problems left, opened new thread here:

 

- black rectangle fades in/out of upper-left-screen quadrant on opening any lua file (module)

- a broken video (mov) transition 



[TOPIC: post.html]
#18

beernathan

[GLOBAL: userInfoPane.html]
beernathan
  • Contributor

  • 357 posts
  • Corona SDK

Rob will be happy to hear that I've finally made the leap and implemented G2.0 with compat=1 to get me up to the current version of Corona. There were *lots* of pitfalls - porting to compatibility=1 is not as easy as it sounds. I'd be happy to write up the challenges, but I figure I'm one of the last on G1.0 - if there's a need let me know and I'll write it up.

 

Thanks,

Nathan.



[TOPIC: post.html]
#19

davidcondolora

[GLOBAL: userInfoPane.html]
davidcondolora
  • Contributor

  • 171 posts
  • Corona SDK

@beernathan: I wouldn't mind hearing about the challenges. I went through basically all of the process before hitting some show-stopper problems (which Corona helped me get past), but I haven't gone back to it since, as I was able to submit with G1.0. But I will eventually have to modernize like everyone else, so any insight is helpful!

 

- David



[TOPIC: post.html]
#20

beernathan

[GLOBAL: userInfoPane.html]
beernathan
  • Contributor

  • 357 posts
  • Corona SDK

So the big changes were...

 

1. Text edit - needs to conform with the new widget.

 

2. Buttons: Having alpha=0 was OK before G2.0, but now it acts like isVisible = false, so you need to have an alpha greater than 0 if you want it to receive touch or tap events.

 

3. Text: If you use the new style of text creator (which has alignment) then you need to change all x,y coordinates used on creation to establish position - they are now top left (were mid points)

 

4. ScrollWidget: A couple big things changed. The coordinates of items in the scrollview are now relative to the whole screen - used to be relative to the scrollview group only. Also (and this took me ages!) when created they scroll a little down (or right, depending on the scroll axis). When you grab them and they bounce back they are fine again. The only way to resolve this was to use a scrollToPosition command when first showing the scrollview - this resets the scroll the first time, and it's fine from there on..

 

That's what I had noted down - could be other surprises though ;-)

 

Nathan.



[TOPIC: post.html]
#21

euphoriacorona

[GLOBAL: userInfoPane.html]
euphoriacorona
  • Contributor

  • 133 posts
  • Corona SDK

Nate, buttons/objects should have zero alpha (or make them is visible = false) if you want them to recieve touch events but not have them visible.

You should use the property "isHitTestable" to allow them to recieve touch events.

i.e.

MyButton.isHitTestable = true

[TOPIC: post.html]
#22

davidcondolora

[GLOBAL: userInfoPane.html]
davidcondolora
  • Contributor

  • 171 posts
  • Corona SDK

@beernathan: Thanks for the write-up! I had no idea that alpha = 0 now acts like isVisible = false. I usually use isVisible and isHitTestable, but odd that they changed the alpha behavior. Thanks!



[TOPIC: post.html]
#23

beernathan

[GLOBAL: userInfoPane.html]
beernathan
  • Contributor

  • 357 posts
  • Corona SDK

Ahh, makes sense - thx @euphoriacorona



[TOPIC: post.html]
#24

euphoriacorona

[GLOBAL: userInfoPane.html]
euphoriacorona
  • Contributor

  • 133 posts
  • Corona SDK

Ahh, makes sense - thx @euphoriacorona


Np :)

[TOPIC: post.html]
#25

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,922 posts
  • Enterprise

I believe that .alpha = 0 has always prevented touch events unless .isHitTestable is set.

 

Rob




[topic_controls]
Page 1 of 2 1 2
 
[/topic_controls]