Create sceneobject, assign graphic and move it

  • #1, by PanSSaturday, 04. September, 18:48 2 weeks ago
    Its not so hard for me to take a object from a scene and move it to a point, scale it or something similar in lua. But how I can create an object and assign a graphic in lua?

    local tmpObj = game.CurrentScene:create(VSceneObjects, "temp")
    1
    2

    works, there is a new object, but I dont find a way to give it a graphic (sprite?).

    Example of (diffent) things I want to do:

    -Player clicks and a ball is thrown through the scene.

    - Putting back an item by right clicking: A graphic of the object is shown near the cursor position and the item is moving to the inventory symbol. (generating an object as part of the scene is maybe not the best idear)

    Some approach?

    Newbie

    65 Posts


  • #2, by SimonSSaturday, 04. September, 22:23 2 weeks ago
    obj = game.CurrentScene:create(VSceneObjects, "temp0")
    obj:create(VObjectSprite, "")
    obj.Sprite.Sprite = {path="Knight_PICKUP_FRONT_LOW_0001.png", position={x=200,y=200}, transparency=2, transpcolor=0,pause=0}
    1
    2
    3

    Works currently not in the live scene as I wrote already, that'll be patched in the next update.

    To move the object I'd recommend offset.

    If you want particles to throw around and recollect, you might better do it with lua draw and mouse event handlers.

    Thread Captain

    1459 Posts

  • #3, by PanSSaturday, 04. September, 23:28 2 weeks ago
    Thx. That works in 5.0.9 so far.

    But I dont understand why it's not necessary to write "vispath:..." like it's common for sounds or loading an image for a draw-frunction?

    Newbie

    65 Posts

  • #4, by SimonSSunday, 05. September, 08:53 2 weeks ago
    Well, once it's getting exported there should be vispath:, for the test I didn't put it in. It's just a marker, so that these images will be exported.

    Thread Captain

    1459 Posts

Write post