Problem with display.setDefault( "textureWrapX", "repeat" )

Hi @Fat Red Couch,

In my tests, this can be set (must be set) any time that you want to make a repeating pattern fill. Then, just reset back to “clampToEdge” when you’re done filling the object(s). I haven’t noticed any specific need to do this on the first frame of the app… as long as you set it directly before you do the fill, then revert it afterward, everything should work out fine. If it’s not in your case, I’d have to see a code sample or projects exhibiting so.

Best regards,

Brent

I attached a modified version of the PatterFill main.lua which demonstrates the problem clearly.

All I did was wrap the code, starting from the first display.setDefault() call down to the bottom in a 1sec. timer delay. I made no other modifications to the code.

If you set the delay to 0, the app launches as it should. If you change it back to 1000, you’ll see that when the texture *does* show up, it shows up much different (the “repeat” is no longer being honored, even though it is using the same exact code — the only change was the timer interval).

Edit: I attached the main.lua file in the post editor but it doesn’t seem to be showing up. Here’s the modified main.lua file for PatternFill (only two additional lines were added for the timer).

-- -- Abstract: repeating fills sample app, demonstrating how to use repeating fills with transitions and filter effects -- -- Date: October 2013 -- -- Version: 1.0 -- -- File name: main.lua -- -- Author: Corona Labs -- -- Demonstrates: graphics, fills, textures, filters, transitions -- -- File dependencies: none -- -- Target devices: Simulator and devices -- -- Limitations: -- -- Comments: -- -- Sample code is MIT licensed, see http://www.coronalabs.com/links/code/license -- Copyright (C) 2010 Corona Labs Inc. All Rights Reserved. --------------------------------------------------------------------------------------- display.setStatusBar( display.HiddenStatusBar ) -- Create container for visual objects local myContainer = display.newContainer( 570, 570 ) myContainer.x = display.contentCenterX myContainer.y = display.contentCenterY -- Place Corona logo local x,y = display.contentCenterX, display.contentCenterY local logo = display.newImage( "corona-logo-large.png" ) myContainer:insert( logo ) logo.fill.effect = "filter.wobble" logo.fill.effect.amplitude = 10 local water1 = display.newRect( 0,0,800,800 ) myContainer:insert( water1 ) local water2 = display.newRect( 0,0,800,800 ) myContainer:insert( water2 ) -- Calculate scale factor for repeating textures local scaleFactorX = 1 ; local scaleFactorY = 1 if ( water1.width \> water1.height ) then scaleFactorY = water1.width / water1.height else scaleFactorX = water1.height / water1.width end -- Set defaults for repeated textures which follow timer.performWithDelay(1000, function() display.setDefault( "textureWrapX", "repeat" ) display.setDefault( "textureWrapY", "mirroredRepeat" ) -- Apply repeating textures and filters to objects water2.fill = { type="image", filename="water-fill.png" } water2.fill.scaleX = 0.25 \* scaleFactorX water2.fill.scaleY = 0.25 \* scaleFactorY water2.fill.rotation = 40 water2.fill.effect = "filter.wobble" water2.fill.effect.amplitude = 6 water2.alpha = 0.4 water1.fill = { type="image", filename="water-fill.png" } water1.fill.scaleX = 0.25 \* scaleFactorX water1.fill.scaleY = 0.25 \* scaleFactorY water1.fill.effect = "filter.wobble" water1.fill.effect.amplitude = 6 water1.alpha = 0.9 -- Reset texture wrap modes display.setDefault( "textureWrapX", "clampToEdge" ) display.setDefault( "textureWrapY", "clampToEdge" ) -- Begin repeating transition function local function repeatTrans() transition.to( water1.fill, { time=4000, x=water1.fill.x+0.5, onComplete=repeatTrans }) transition.to( water2.fill, { time=4000, x=water1.fill.x+0.5 }) if ( logo.alpha == 1 ) then transition.to( logo, { time=3000, alpha=0.8, transition=easing.inOutQuad } ) transition.to( water1, { time=3000, alpha=1, transition=easing.inOutQuad } ) transition.to( water2, { time=3600, alpha=0.6, transition=easing.inOutQuad } ) else transition.to( logo, { time=3000, alpha=1, transition=easing.inOutQuad } ) transition.to( water1, { time=3000, alpha=0.9, transition=easing.inOutQuad } ) transition.to( water2, { time=3600, alpha=0.4, transition=easing.inOutQuad } ) end end repeatTrans() end, 1);

Hi @Fat Red Couch,

Thanks for the code sample, but I’m just not seeing an issue. I copied your exact code above (timer included) and ran the project both in the Simulator and compiled on my iPhone5. The pattern shows up properly each time, and it honors the repeat. This was done using build #2100.

Best regards,

Brent

@Fat Red Couch,

Are you still having this problem? I am having the exact same behavior using the latest build (2181). 

I am using power of 2 textures

@Fat Red Couch,

Are you still having this problem? I am having the exact same behavior using the latest build (2181). 

I am using power of 2 textures