Collect Item Interface

  • #1, by theoSunday, 28. March, 01:05 8 months ago
    Hi Forum,

    thanks for many helpful tips that have already been posted here. You have already helped me in many concerns without knowing it! Now I have a question to which I have not yet found an answer...

    It's about an interface that is displayed a few seconds after the character has collected an item, with a small image of the collected object. 
    Unfortunately I'm not a good programmer to write a script quickly.... was there already a thread here that deals with this? Or does anyone have an idea how I approach this? 

    Thanks in advance!  


    Newbie

    2 Posts


  • #2, by afrlmeThursday, 01. April, 00:47 8 months ago
    A'llo, this is a working script shared by Simon on our discord server a little while ago. It's supposed to popup the item sprite at a specific position temporarily after adding a new item to the inventory.

    Add this as a definition type script to the script section of the Visionaire Studio. You will need to tweak the position values to wherever you want the popup item sprite to be displayed.

    local ADD_REMOVE_ITEM = 150
    system.registerActionPartHook(ADD_REMOVE_ITEM, "addRemoveItem")
    function addRemoveItem(actionPart)
    if actionPart.Int == 0 then
    local path = actionPart.Link.Sprite.Sprite:getPath()
    local sprite = graphics.loadFromFile(path)
    sprite.position = graphics.getCharacterTextPosition(game.CurrentCharacter)

    local t = getTime()
    graphics.addDrawFunc("draw()", 0)
    function draw()
    local ct = getTime() - t
    local alpha = 0
    if ct > 3000 then
    graphics.removeDrawFunc("draw()")
    elseif ct > 2000 then
    alpha = graphics.evalTween(1, 0, ct/1000-2,easeQuadOut)
    elseif ct > 1000 then
    alpha = 1
    else
    alpha = graphics.evalTween(0, 1, ct/1000,easeQuadOut)
    end
    graphics.drawSprite(sprite, alpha, 0xffffff)
    end
    end
    return false
    end
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27


    Imperator

    7036 Posts

  • #3, by afrlmeThursday, 01. April, 00:52 8 months ago
    Ah, I just read through the code, it seems that it fades in/out the item sprite above the playable characters head. If you want to change the position, then just edit line 7.
    sprite.position = graphics.getCharacterTextPosition(game.CurrentCharacter)
    1

    to something like this...

    sprite.position = {x = game.ScrollPosition.x + 100, y = game.ScrollPosition.y + 100}
    1


    Which would offset the item popup 100 pixels from the top-left of the current camera viewport.

    Imperator

    7036 Posts

  • #4, by theoThursday, 01. April, 14:46 8 months ago
    Many thanks AFRLme & Simon!

    Works perfectly... I'll create a standardized animation soon, which then plays in the lower left corner, the item appears briefly, both disappear shortly after... should look great!



    Newbie

    2 Posts

Write post