Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


edited March 2019 in General Posts: 18

I’m trying to bring a simple sprite into my 3d scene and I either get an error saying it is null, or if I call up it as a scene entity, it now doesn’t even show up.

If someone can help me out, it would be awesome.

Here’s my current coding, where I get no errors, but the sprite doesn’t show up.

function setup()
    -- Create the scene
    scene = craft.scene()
  -- Move the main camera = -12

    mySprite = scene:entity()

    mySprite = sprite("Documents:TEXT BUBBLE",WIDTH/2,HEIGHT/2,1024)
  -- Adjust the scene lighting
  scene.sun.rotation = quat.eulerAngles(30,0,0)
  scene.ambientColor = color(10, 10, 10, 255)

  -- Turn on fog and set distances and color
  scene.fogEnabled = true
  scene.fogNear = 2
  scene.fogFar = 18
  scene.fogColor = color(127, 127, 127, 117)

  -- Get the sky material and change the sky and horizon colors = color(85, 128, 217, 255)
  skyMaterial.horizon = color(194, 195, 220, 255)


function update(dt)
    -- Update the scene (including physics, voxels and other systems)


function draw()


    -- Draw the scene (must be done within the draw function)



  • When I add
    mySprite.x = 1

    It comes up with a new error

  • JohnJohn Admin Mod
    Posts: 625

    Hi @Kurall_Creator

    This is because the sprite() function does not return any values. It draws a sprite immediately on top of the current background (and only in that frame). If you want to put a sprite in the scene you'll have to set the model and material for your mySprite entity and set the material to use the image you want. If you just want to draw on top of the scene then put your sprite call after scene:draw() and it will appear in front of everything else.

  • Thanks for replying John.

    I came to that conclusion as well, and I found an ingenious way to ensure the position of the sprites could change when you touched the screen - which was what I was looking for - creating a touch sensitive cutscene.

Sign In or Register to comment.