| Name | Typ | Von |
|---|---|---|
| Benutzerdefiniertes System zum Ziehen von Gegenständen | Definition | Christopher A. Sommer |
Dieses Skript ist eine Alternative zum Standard-Ziehen von Items in Visionaire Studio. Es zeichnet ein angeklicktes Item neben dem Cursor und lässt den Item-Cursor auf verschiedene Arten auf Objektbereiche reagieren (skalieren, drehen usw.). Über die Parameter oben im Skript passt du das Verhalten an.
Anweisungen
- Füge das Hauptskript im Skripteditor von Visionaire Studio hinzu und lege es als Definitionsskript fest.
- Schalte das Standard-Ziehen aus, indem du in den Spieleigenschaften Allow dragging of items from inventory deaktivierst und/oder bei allen Befehls-Buttons Items can be dragged with this command.
- Wähle für den Befehls-Button, mit dem Items gezogen werden sollen, den Befehlstyp „Kombinierter Befehl“.
- Verwende in deinen Aktionen zum Kombinieren eines Items mit einem Objekt, Charakter oder Item nicht den Ausführungstyp „Item fallen gelassen“, sondern „Ausgeführter Befehl“, und wähle das Item (kombinierter Befehl).
Hauptskript
local ItemSprite
-- SET OFFSET NEXT TO MOUSE-CURSOR:
local X_Offset = 32
local Y_Offset = -16
-- SET GENERAL SCALE AND SCALE-WOBBLE WHEN ACTIVE:
local ItemScale
local ItemScaleGeneral = 0.75
local ItemScaleFactor = 0.025 -- 0.0 to deactivate scale-wobble
local ItemScaleSpeed = 0.0125 -- 0.0 to deactivate scale-wobble
-- SET ROTATION-WOBBLE WHEN ACTIVE:
local ItemRot
local ItemRotationFactor = 0.2 -- 0.0 to deactivate rotation-wobble
local ItemRotationSpeed = 0.5 -- 0.0 to deactivate rotation-wobble
-- SET ALPHA WHEN INACTIVE AND ACTIVE:
local ItemAlpha
local ItemAlphaInactive = 0.75
local ItemAlphaActive = 1.0
-- SET COLOR WHEN INACTIVE AND ACTIVE:
local ItemColor
local ItemColorInactive = 0xdddddd
local ItemColorActive = 0xffffff
---
graphics.addDrawFunc("ItemDragCustom()",1)
function ItemDragCustom()
--if game.UsedItem then
if not game.UsedItem:isEmpty() then
ItemScale = ItemScaleGeneral
--
if game.CurrentObject:isEmpty() then
ItemScale = ItemScaleGeneral
ItemRot = 0.0
ItemAlpha = ItemAlphaInactive
ItemColor = ItemColorInactive
else
ItemScale = ItemScaleGeneral + (ItemScaleFactor * math.sin(getTime() * (ItemScaleSpeed) ))
ItemRot = ItemRotationFactor * math.sin(getTime() * (ItemRotationSpeed*0.01) )
ItemAlpha = ItemAlphaActive
ItemColor = ItemColorActive
end
--
ItemSprite = graphics.loadFromFile( game.UsedItem.Sprite.Sprite:getPath() )
ItemSprite.position = {
x = (getCursorPos().x + X_Offset),
y = (getCursorPos().y + Y_Offset)
}
ItemSprite.rotationCenter = {
x=ItemSprite.position.x + (ItemSprite.width/2),
y=ItemSprite.position.y+(ItemSprite.height/2)
}
ItemSprite.scale = ItemScale
ItemSprite.rotation = ItemRot
graphics.drawSprite( ItemSprite , ItemAlpha , ItemColor)
end
end
game.DraggableItems = false
function Unuse(eventType)
if eventType == eEvtMouseRightButtonUp then
game.UsedItem = emptyObject
end
end
registerEventHandler("mouseEvent", "Unuse")