Can't draw a circle

Sorry - probably being stupid but can someone tell me why my following code is drawing a rectangle:

local myCircle = display.newCircle( 200, 200, 10)
myCircle:setFillColor(128,0,128)

Thanks

Adrian [import]uid: 83824 topic_id: 14990 reply_id: 314990[/import]

Is that the whole code? Are you perhaps applying a physics body to the circle afterward? [import]uid: 64596 topic_id: 14990 reply_id: 55341[/import]

Hi Shane, while it isn’t the whole code, I do not apply any physics at all as yet. I have an image of a map and I am trying to put little circles on it to indicate towns.

Thanks

Adrian [import]uid: 83824 topic_id: 14990 reply_id: 55344[/import]

Update: - display.newline also gives me a rectangle. Do I need to “require” something.
local TestLine = display.newLine(200, 115, 215,140)
TestLine .width = 1
localGroup:insert(TestLine)

Adrian [import]uid: 83824 topic_id: 14990 reply_id: 55357[/import]

What build of Corona SDK are you using?

FYI, I just tried out Particle Candy, and all I got was white squares (on simulator) even though the sample folder has PNG files. I was using Corona build version 606.

Since Particle Candy just got updated, I thought I might just need to update my Corona SDK to the latest daily build too – and as soon as I updated mine to build version 617, the white squares vanished, replaced by proper images.

What I experienced might have nothing to do with what you are seeing, but I thought it wouldn’t hurt to mention…
[import]uid: 67217 topic_id: 14990 reply_id: 55375[/import]

Thanks ask, just downloaded the latest build (2011.617) but the same problem persists. Instead of drawing a line or circle (display.newLine or display.newCircle) I get a rectangle.

Adrian [import]uid: 83824 topic_id: 14990 reply_id: 55444[/import]

Daily builds should not be presumed stable or even functional.

Please use build .591 (the last stable release) if you experience problems with daily builds :slight_smile:

Peach [import]uid: 52491 topic_id: 14990 reply_id: 55488[/import]

@adrian9, you must be doing something in addition to four lines of code you supplied.

I added the following to the very bottom of my lua file, and they appeared on top of all the other elements on the screen without any problem.

[code]
– this looks like a magenta circle on simulator using the latest build (2011.617)
local myCircle = display.newCircle( 200, 200, 10)
myCircle:setFillColor(128,0,128)

– this looks like a slanted white line on simulator using the latest build (2011.617)
local TestLine = display.newLine(200, 115, 215,140)
TestLine .width = 1
[/code] [import]uid: 67217 topic_id: 14990 reply_id: 55512[/import]

@peach, I guess I should let the particle candy people know about the white square I saw? [import]uid: 67217 topic_id: 14990 reply_id: 55514[/import]

Hi ask, it must be something I am doing. I took your code and put it in an empty main.lua file and it worked perfectly. I then put it in my code and all I get are rectangles!!!

Adrian

UPDATE:

I’ve done some testing and the problem lies when trying to draw a line on top of a background image. I’ve set up a quick test project. When the image and the line do not connect, there’s no problem. When I introduce my “config.lua” which turns it to landscape and zooms, the image fills the screen and the line turns into a rectangle. I have tried the “scale” as “zoomeven”, “letterbox” and “none” and get the same result.

Anybody any ideas?

Thanks

Adrian [import]uid: 83824 topic_id: 14990 reply_id: 55988[/import]

Hi Adrian,

I use:

portrait, letterbox
background image (png file) that covers the entire screen)
lots of images, circles, rectangles and text on top of the background image.

You may want to look at how you display background image? I don’t think it’s about drawing a line on top of a background image that’s causing the problem. There must be something else going on. [import]uid: 67217 topic_id: 14990 reply_id: 56043[/import]

It sounds like something has overwritten the function definitions.

You can do:

display.newCircle = someotherfunction and suddenly newCircle has different behavior.

A popular hack, er. addition is to override display.newText with a function that detects retina displays and rescales the text accordingly. So its possible something you’re requiring is doing something weird to those two functions.

[import]uid: 19626 topic_id: 14990 reply_id: 56048[/import]

Thanks to all you guys for taking the time to try to help. I have to say this is driving me bananas! I know its because I am new to Corona (experienced VB developer) and I am missing something. At the risk of testing everyone’s patience too far, I am enclosing the test program that goes wrong to see if anyone can spot something quickly:

--------------------MAIN.LUA-----------------------------------

display.setStatusBar (display.HiddenStatusBar)

local director = require (“director”)

local mainGroup = display.newGroup()

local function main()

mainGroup:insert(director.directorView)

director:changeScene(“Firstscreen”)

return true
end

main()

----------------------FIRSTSCREEN.LUA-------------------------

module(…, package.seeall)

function new()
local localGroup = display.newGroup()

local _w = display.contentWidth
local _h = display.contentHeight

local backg = display.newImageRect (“blueworld.png”,480,320)

backg.x = _w/ 2
backg.y = _h/ 2
localGroup:insert(backg)

local myline = display.newLine(20, 20, 215,140)
myline.width = 5
myline:setColor( 255, 102, 102, 255 )

return localGroup

end

-------------------CONFIG.LUA-----------------------------------

application =
{
content =
{
width = 320,
height = 480,
scale = “none”,
– fps = 30,
antialias = true,

imageSuffix =
{
["-x15"] = 1.5,
["-x2"] = 2, },

},
}

-----------------------BUILD.SETTINGS--------------------

settings =
{
orientation =
{
default = “landscapeRight”,
supported =
{
“landscapeRight”, “landscapeLeft”
},
},

iphone =
{
plist =
{
UIStatusBarHidden=true,
UIPrerenderedIcon = true
},
}

}


As I say this gives me the correct background image but also a largish red rectangle instead of a line.

Thanks

Adrian (in a rainy UK!)

[import]uid: 83824 topic_id: 14990 reply_id: 56134[/import]

Hi Adrian, with director class, you need to insert display objects to localGroup. For example, in FIRSTSCREEN.LUA, you did not insert myline to localGroup. Try inserting it.

EDIT:
I hardly ever draw a line in my code, so I thought maybe I should check this out. So, I inserted myline to my file that uses director class, and the line appeared on top of everything without any problem:

local myline = display.newLine(20, 20, 215,140)  
myline.width = 5  
myline:setColor( 255, 102, 102, 255 )   
localGroup:insert(myline);   

EDIT2:
You also want to change the way you do the newImageRect. Here’s how I do my background (on portrait screen), and how I’d add the line:

 local screenW = display.contentWidth;  
 local screenH = display.contentHeight;  
 local imgWidth;  
 local imgHeight;  
  
 -- background  
 imgWidth = 360;  
 imgHeight = 480;  
 local background = display.newImageRect( localGroup, "PNG/background.png", imgWidth, imgHeight ) ;  
 background.x = 0.5 \* screenW;  
 background.y = 0.5 \* screenH;  
  
 local myline = display.newLine(20, 20, 215,140)  
 myline.width = 5  
 myline:setColor( 255, 102, 102, 255 )   
 localGroup:insert(myline);   

I hope this helps.
[import]uid: 67217 topic_id: 14990 reply_id: 56192[/import]

Thanks again but still no joy. I have copied your code into my firstscreen.lua file (replacing the background png with my own obviously!) and still I get a rectangle instead of a line. If you try to run my test project, does it work on yours - wondering if its anything to do with my setup.

Adrian [import]uid: 83824 topic_id: 14990 reply_id: 56287[/import]

I didn’t see anything wrong with the rest of your code – and it puzzled me. So I went ahead and slapped together the project file that contain:

build.settings – copied directly from the above
config.lua – copied directly from the above
directlor.lua – v1.4
firstscreen.lua – copied from above with the local displayGroup rewritten to match with what I wrote in #13 above
main.lua – copied directly from the above
PNG folder (with background.png inside)

And it worked perfectly fine when I run the simulator. Because it works perfectly as expected on my simulator, I have no clue why you are having a problem you describe. You may need a direct help from Ansca support team.

You probably should provide the version/build of Corona SDK you are using (and is it on windows or mac?) along with a screen capture of what you get when you run it on simulator.

Good luck.
[import]uid: 67217 topic_id: 14990 reply_id: 56329[/import]

If you’re getting the problem on a stable release (.591) then I’d say yes, submit your info and code here; http://developer.anscamobile.com/forms/support [import]uid: 52491 topic_id: 14990 reply_id: 56365[/import]

Thanks everyone, I will submit my issues to the link that Peach enclosed. I’ve thought of a different way of doing what I’m trying to do but at some stage I might want to draw circles or lines above other images so I’ll need to get it sorted.

Thanks again

Adrian [import]uid: 83824 topic_id: 14990 reply_id: 56501[/import]

@adrian9 What version of Windows are you using? I’ve got a machine running XP Pro SP3 that I sometimes use and I’ve had the same problem with circles and lines from day 1. Same code works flawlessly on Mac. I always figured it was the old OS and it never really hampered me because I always build on the Mac. [import]uid: 40137 topic_id: 14990 reply_id: 58416[/import]

I am using Windows 7 professional. Interesting that you get the same problem. My problem with lines and circles only occurs if I am trying to draw them above a background image. If I have no background image loaded, the circle and line functions work fine.

Adrian [import]uid: 83824 topic_id: 14990 reply_id: 58844[/import]