Hi. I got this code from the documentation, then i tried to make it rectangular.
local physics = require("physics") physics.setDrawMode("hybrid") physics.start() local bullet = display.newRect( 0, display.contentCenterY, 100, 20) physics.addBody( bullet, "dynamic" ) bullet.gravityScale = 0 -- Make the object a "bullet" type object bullet.isBullet = true bullet:setLinearVelocity( 800, 0 )
I understand that I may repeatedly produce this through timer.performWithDelay, or “enterframe” listener, or through transition.to instead of Linear Velocity, particle system, ray casting and etc.
As a training and practice for me as a rookie, I will make a shooting object. But I don’t know how to start because of thinking-when the gun aims to shoot vertically, the bullet may travel in horizontal position, and more bad is when the gun randomly shoot slantingly.
How can I make the rectangular objects travels correspondingly to it’s rotation position, or travel accordingly where it’s rotation is pointing?
Please, I really need help from you. And a sample code or project will be indeed an elevation for me, its really a BIG help. thank you so much.