BruceAB12
|
  |
| Joined: 19 Jan 2012 |
| Total Posts: 3238 |
|
|
| 30 Apr 2014 05:26 PM |
| How does the function TweenPosition work...functionally? Is it using some sort of interpolation? TweenPosition has always puzzled me...If someone can explain how it functions that'd be great. :) |
|
|
| Report Abuse |
|
|
|
| 30 Apr 2014 05:34 PM |
guiframe:TweenPosition(UDim2.new(0,0,0,0),"Out","Linear",0.2,true)
Udim2 is basically vector3 for guis. It contains the end position of the gui tweening.
TweenPostion(endUdim2,don't worry about this,don't worry about this, duration of gui movement,bool that determines if the gui being tweened will overlap other guis)
In other words, :TweenPosition moves around guis, and can lead to catastrophic animations.
Next time, post this in Scripting Helpers. |
|
|
| Report Abuse |
|
|
BruceAB12
|
  |
| Joined: 19 Jan 2012 |
| Total Posts: 3238 |
|
|
| 30 Apr 2014 05:44 PM |
| You didn't explain it functionally...You explained what it does. |
|
|
| Report Abuse |
|
|
morash
|
  |
| Joined: 22 May 2010 |
| Total Posts: 5834 |
|
| |
|
lolb3
|
  |
| Joined: 16 Jan 2010 |
| Total Posts: 2268 |
|
|
| 30 Apr 2014 06:06 PM |
| it uses a numeric for loop and moves the frame distance/time px per second |
|
|
| Report Abuse |
|
|
|
| 30 Apr 2014 06:16 PM |
Oh.. Misread your question. Sorry. |
|
|
| Report Abuse |
|
|
BruceAB12
|
  |
| Joined: 19 Jan 2012 |
| Total Posts: 3238 |
|
|
| 30 Apr 2014 06:43 PM |
| How would this numeric for loop look like e.e ? |
|
|
| Report Abuse |
|
|
stravant
|
  |
 |
| Joined: 22 Oct 2007 |
| Total Posts: 2893 |
|
|
| 30 Apr 2014 06:54 PM |
It is not implemented as a "for loop" of sorts, here's the way it works:
local ListOfThingsToTween = {}
RenderStepped:connect(function() for _, thing in pairs(ListOfThingsToTween) do local elapsed = tick() - thing.StartTweenAt if elapsed > thing.TweenTime then thing.Gui.Position = thing.TweenEndPos [remove thing from the list] else local fracDone = elapsed / thing.TweenTime thing.Gui.Position = tween(thing.TweenStartPos, thing.TweenEndPos, fracDone) end end end)
function TweenPosition(gui, position, time) table.insert(ListOfThingsToTween, { StartTweenAt = tick(); TweenStartPos = gui.Position; TweenEndPos = position; TweenTime = time; Gui = gui; }) end
Something like that but in C++ code. |
|
|
| Report Abuse |
|
|
BruceAB12
|
  |
| Joined: 19 Jan 2012 |
| Total Posts: 3238 |
|
|
| 30 Apr 2014 06:58 PM |
| Ah...interesting, thank you so much :) |
|
|
| Report Abuse |
|
|
BruceAB12
|
  |
| Joined: 19 Jan 2012 |
| Total Posts: 3238 |
|
|
| 30 Apr 2014 07:03 PM |
| The thing is that I wanted to create a TweenPosition Function with a 2D GameEngine called love2D, and I have no idea how to do so. :/ |
|
|
| Report Abuse |
|
|
MettaurSp
|
  |
| Joined: 20 Mar 2010 |
| Total Posts: 3179 |
|
|
| 30 Apr 2014 07:06 PM |
for var=start,end,increment do print(var) end |
|
|
| Report Abuse |
|
|
MettaurSp
|
  |
| Joined: 20 Mar 2010 |
| Total Posts: 3179 |
|
|
| 30 Apr 2014 07:06 PM |
| Aaand late post. Note to self: refresh pages after leaving them for a bit to check for new replies o3o |
|
|
| Report Abuse |
|
|
BruceAB12
|
  |
| Joined: 19 Jan 2012 |
| Total Posts: 3238 |
|
|
| 30 Apr 2014 07:07 PM |
| lol its fine maybe I could use that :) |
|
|
| Report Abuse |
|
|
BruceAB12
|
  |
| Joined: 19 Jan 2012 |
| Total Posts: 3238 |
|
|
| 30 Apr 2014 07:11 PM |
function updateAirplane(dt) for _,v in ipairs(airplane) do v.x = v.x + (v.x1-v.x0) * dt * date.speed v.y = v.y + (v.y1-v.x0) * dt * date.speed if v.x0 > v.x1 and v.x > v.x1 then v.x = v.x1 elseif v.x0 < v.x1 and v.x < v.x1 then v.x = v.x1 end if v.y0 > v.y1 and v.y > v.y1 then v.y = v.y1 elseif v.y0 < v.y1 and v.y < v.y1 then v.y = v.y1 end if v.x == v.x1 and v.y == v.y1 then landed = true table.remove(airplane,id) end end end
v.x , v.y = images position v.x1,v.y1 = images end position v.x0, v.y0 = images initial position dt = delta time date.speed = 1
I tried to use interpolation to move the image, however it did not function correctly. :P |
|
|
| Report Abuse |
|
|