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

Is that the whole code? Are you perhaps applying a physics body to the circle afterward?

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

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

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...

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

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 :)

Peach

@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.

1
2
3
4
5
6
7
-- 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

@peach, I guess I should let the particle candy people know about the white square I saw?

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

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.

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.

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!)

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:

1
2
3
4
local myline = display.newLine(20, 20, 215,140)
myline.width = 5
myline:setColor( 255, 102, 102, 255 )   
localGroup:insert(myline);      
views:2273 update:2011/9/25 12:40:18
corona forums © 2003-2011