ShadowMario / FNF-PsychEngine

Engine originally used on Mind Games mod
Apache License 2.0
1.15k stars 2.23k forks source link

How can I make a draggable object using the mouse? #15904

Open MaksPRO12667 opened 1 week ago

MaksPRO12667 commented 1 week ago

Describe your problem here.

Script:

function onCreatePost() makeLuaSprite('mouseF', '', 0, 0) setProperty('mouseF.alpha', 1) makeGraphic('mouseF', 5, 5, 'ffffff') setScrollFactor('mouseF', 0, 0) setObjectCamera('mouseF', 'other') addLuaSprite('mouseF', true)

makeLuaSprite('sprite', 'sprite', 500, 500)
  setObjectCamera('sprite', 'other')
  addLuaSprite('sprite', false);
  scaleObject('sprite', 0.3, 0.3)
 setProperty('sprite.alpha', 0.5)

end

function onUpdate(elapsed) setProperty('mouseF.x', getMouseX('other')) setProperty('mouseF.y', getMouseY('other')) if objectsOverlap('mouseF','sprite') then setProperty('sprite.alpha', 1) if mousePressed('left') then setProperty('sprite.x', ?) setProperty('sprite.y', ?) end else setProperty('sprite.alpha', 0.6) end end

I want to somehow grab an object(sprite) with the mouse

Are you modding a build from source or with Lua?

Lua

What is your build target?

Windows x64

Did you edit anything in this build? If so, mention or summarize your changes.

No response