Skip to content

Instantly share code, notes, and snippets.

@scottrules44
Created February 7, 2017 03:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottrules44/1d9ed47d7550655474e64886a96489b8 to your computer and use it in GitHub Desktop.
Save scottrules44/1d9ed47d7550655474e64886a96489b8 to your computer and use it in GitHub Desktop.
--how to add a model
--local myRock = sceneKit.newModel(system.pathForFile("objs/bloc.scn"), "stoneMysterious")
--sceneKit.addPhysics(myRock, "dynamic")
local sceneKit = require "plugin.sceneKit"
sceneKit.init()
sceneKit.cameraZ(1000, 0)
sceneKit.setBackgroundColor(1,1,1,0)
sceneKit.setFps(30)
sceneKit.setGravity(0,-100,0)
local camera = sceneKit.getCameraNode()
camera.rotationX = -180
camera.z = 0
camera.y = 300
local box = sceneKit.newBox(30,30,30)
local createImage=system.pathForFile("crate.png")
sceneKit.addPhysics(box, "dynamic")
box.y = 40
box.rotationX = 40
box.rotationZ = 40
box:setMaterial({createImage, createImage, createImage, createImage, createImage, createImage}) -- note 6 for cube
local groundImage=system.pathForFile("ground.png")
local ground = sceneKit.newBox(100,20,40)
ground.y = -50
sceneKit.addPhysics(ground, "static")
ground:setMaterial({groundImage, groundImage, groundImage, groundImage, groundImage, groundImage}) -- note 6 for cube
--corona
local physics = require( "physics" )
physics.start()
local sky = display.newImage( "bkg_clouds.png", 160, 195 )
local ground = display.newImage( "ground.png", 160, 445 )
physics.addBody( ground, "static", { friction=0.5, bounce=0.3 } )
local crate = display.newImage( "crate.png", 180, -50 )
crate.rotation = 5
physics.addBody( crate, { density=3.0, friction=0.5, bounce=0.3 } )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment