This program that I have been working is behaving like some of my classes are functions.
On my iPad, it errors out at
ball = Ball()
in the code below, saying that there inst any “function parameters”
Game = class()
function Game:init()
gameState = PLAYING
rope:ropeUpdate
ball = Ball()
walls = Walls()
tac = Tac()
rope = Rope()
end
Here is my ball class
Ball = class()
function Ball:init()
self.d = 75
self.ball = physics.body(CIRCLE,self.d/2)
self.ball.x = WIDTH/2
self.ball.y = HEIGHT/2
self.ball.gravityScale = 1
self.ball.restitution = .5
self.ball.friction = 1
self.ball.linearVelocity = vec2(0,253)
end
function Ball:draw()
pushStyle()
fill(229, 16, 36, 255)
ellipse(self.ball.x,self.ball.y, self.d)
popStyle()
end
function Ball:getBall()
return self.ball
end
But, here’s where the plot thickens, in air code, it errors in main when I try to create a Game() with
game = Game()
In the following code of Main saying that its a function just like the ball error.
-- Ball Project
function setup()
game = Game()
end
function draw()
background(31, 32, 53, 255)
game:draw()
end
It especially confuses me why I’m getting 2 different error codes. Is the Air Code editor broken or something?
And I NEVER define a function any of the names of my classes.
Any ideas as to what the cause of this is? I’ve tried for a couple hours and think that a different set of eyes would do it well. Thank you, who ever looks at this to help me out
Ill paste my complete Game class to down below
Game = class()
function Game:init()
gameState = PLAYING
rope:ropeUpdate
ball = Ball()
walls = Walls()
tac = Tac()
rope = Rope()
end
function Game:draw()
self:ropeUpdate
rope:draw()
ball:draw()
walls:draw()
tac:draw()
end
function Game:ropeUpdate()
if rope:getRope == nil then
rope:ropeCreateCheck(ball:getBall(), tac:getTac())
end
end