generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: How does TweenPosition Work?

Previous Thread :: Next Thread 
BruceAB12 is not online. 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
Fluffmiceter is not online. Fluffmiceter
Joined: 28 Jan 2012
Total Posts: 6931
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 is not online. 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 is not online. morash
Joined: 22 May 2010
Total Posts: 5834
30 Apr 2014 05:52 PM
Maybe try it?
Report Abuse
lolb3 is not online. 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
Fluffmiceter is not online. Fluffmiceter
Joined: 28 Jan 2012
Total Posts: 6931
30 Apr 2014 06:16 PM
Oh.. Misread your question.
Sorry.
Report Abuse
BruceAB12 is not online. 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 is not online. stravant
Forum Moderator
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 is not online. BruceAB12
Joined: 19 Jan 2012
Total Posts: 3238
30 Apr 2014 06:58 PM
Ah...interesting, thank you so much :)
Report Abuse
BruceAB12 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image