Hi I’m having trouble with the physics engine. Here’s my code please tell me what I’m doing wrong.
–Physics Engine
local physics = require “physics”
physics.start()
physics.setDrawMode(“hybrid”)
–Charecters
local Player1Sprite = display.newRect( 75, 425, 50, 50)
Player1Sprite:setFillColor( 50,50,50)
physics.addBody(Player1Sprite, {bounce = 0.3})
local Player2Sprite = display.newRect( 835, 425, 50, 50)
Player2Sprite:setFillColor( 0,0,0 )
physics.addBody(Player2Sprite, {bounce = 0.3})
–Line for Players Field
local PlayingFieldLine = display.newLine( 55, 525, 920, 525)
PlayingFieldLine:setColor( 0,0,0 )
physics.addBody(PlayingFieldLine, “static”, {bounce = 0.3})
seems fine to me if you change the coordinates a bit … see if this helps
--Physics Engine local physics = require "physics" physics.start() physics.setDrawMode("hybrid") --Charecters local Player1Sprite = display.newRect( 75, 225, 50, 50) Player1Sprite:setFillColor( 50,50,50) physics.addBody(Player1Sprite, {bounce = 0.3}) local Player2Sprite = display.newRect( 200, 225, 50, 50) Player2Sprite:setFillColor( 0,0,0 ) physics.addBody(Player2Sprite, {bounce = 0.3}) --Line for Players Field local PlayingFieldLine = display.newLine( 55, 375, 920, 525) PlayingFieldLine:setColor( 0,0,0 ) physics.addBody(PlayingFieldLine, "static", {bounce = 0.3})
seems fine to me if you change the coordinates a bit … see if this helps
--Physics Engine local physics = require "physics" physics.start() physics.setDrawMode("hybrid") --Charecters local Player1Sprite = display.newRect( 75, 225, 50, 50) Player1Sprite:setFillColor( 50,50,50) physics.addBody(Player1Sprite, {bounce = 0.3}) local Player2Sprite = display.newRect( 200, 225, 50, 50) Player2Sprite:setFillColor( 0,0,0 ) physics.addBody(Player2Sprite, {bounce = 0.3}) --Line for Players Field local PlayingFieldLine = display.newLine( 55, 375, 920, 525) PlayingFieldLine:setColor( 0,0,0 ) physics.addBody(PlayingFieldLine, "static", {bounce = 0.3})