Interpolate from just the right side.

dashnevadadashnevada Member Posts: 58
edited November -1 in Working with GS (Mac)
Hey guys.

Quick question. I have an actor that I want to change in width but just from the right side. If I use an interpolate rule to chance size.width to a bigger value the actor will increase in both left and right sides.. Is there a way to just make the actor width increase on the right side?

Thanks for your help

Comments

  • DrGlickertDrGlickert Member Posts: 1,135
    Hmm, my first thought is that you use two interpolate functions;

    One that interpolates size.width and the other that interpolates self.position.X.

    This would require a lot of "tweaking" to get the effect exactly correct, and it may not even be possible. But if you increased the width but kept moving the object slowly to the left I believe you may be able to achieve the appearance of it moving to the right. But I don't know how this would look or if it would look dumb or not.

    Good luck!
  • DrGlickertDrGlickert Member Posts: 1,135
    Whoa, I just tried it...

    It definitely requires you to spend some time "tweaking" it, but it works. I'll post the demo project that I just made.
  • dashnevadadashnevada Member Posts: 58
    Thanks a lot Dr.

    I appreciate it.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Hi dashnevada; this is because changing width or height is from the centre of the actor, so you need to interpolate the X coordinate at the same time.

    There's a bit of math(s) to do first to get the new X coordinate:

    Decide on your new/final width.
    Minus from that the starting width of the actor.
    Divide this number by 2.
    With this number, add it to the starting X position of your actor.
    This final number will be used for the interpolating of the new X position.

    Example: Actor is 100 wide. You want to make it grow to 300 pixels.
    So 300 - 100 = 200
    Divide by 2 = 100
    Say your starting X pos is 187. So add 187 to the 100 = 287.
    So:

    Interpolate Attribute: self.Size. Width To 300
    Interpolate Attribute: self.Position.X To 287.

    Hope that helps. :-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • DrGlickertDrGlickert Member Posts: 1,135
    Search; Interpolate to "Grow" for the template. Hopefully that helps ya out!

    Good luck!
  • old_kipperold_kipper Member Posts: 1,420
    If you do use 2 interpolates, one for size and the other for position, make sure both use the same speed function such as linear, or ease in, etc. and same time, otherwise you will get weird movement in the transition. Linear is safest in these cases. The new position are based on width increase of the actor and if you want it to stay centrally in the same position or move sideways to accommodate the increase. If the actor increases and moves right, keep the same position, if you want it to increase from centre it is old self position-old self width/2 + new self width/2 = new self position

    edit- gyro and the doc have beaten me to it!!! I was wrong anyway... should have been the difference between 1/2 the new and old widths for the adjustment of the postion
  • dashnevadadashnevada Member Posts: 58
    gyroscope said:
    Hi dashnevada; this is because changing width or height is from the centre of the actor, so you need to interpolate the X coordinate at the same time.

    There's a bit of math(s) to do first to get the new X coordinate:

    Hope that helps. :-)

    Thanks for the info gyro.. The problem is that I the final width or angle of the expanding actor is not fixes. The player is going to decide that. What I'm trying to accomplish is I have a rope actor and there are going to be animals in the screen.. When the user touches the animal I have a cowboy animation that throws the rope to grab the animals.. I figure I interpolate the rope width to the position of the users touch.. Is there any other way to do this?
    DrGlickert said:
    Search; Interpolate to "Grow" for the template. Hopefully that helps ya out!

    Good luck!

    Thanks a lot Dr. I'll check it out.
  • dashnevadadashnevada Member Posts: 58
    Thanks old_kipper.. This was the method I was using but problem is the width doesn't have a fix size. it changes depending on the touch position
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    dashnevada said:
    Thanks for the info gyro.. The problem is that I the final width or angle of the expanding actor is not fixes. The player is going to decide that. What I'm trying to accomplish is I have a rope actor and there are going to be animals in the screen.. When the user touches the animal I have a cowboy animation that throws the rope to grab the animals.. I figure I interpolate the rope width to the position of the users touch.. Is there any other way to do this?

    Thanks a lot Dr. I'll check it out.

    this is perhaps more complex than it sounds. Interesting problem; i've started working on it and I'll post later(if no one else beats me to it!)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • dashnevadadashnevada Member Posts: 58
    gyroscope said:
    this is perhaps more complex than it sounds. Interesting problem; i've started working on it and I'll post later(if no one else beats me to it!)

    Thanks a lot!!
  • old_kipperold_kipper Member Posts: 1,420
    You could fix a sum in the position that is effected by the width and have different underlying position that you use to do offsets from. Have the position controls effect a game real number attribute for the underlying position and then constrain the actor position with an offset of half the current width to that number.
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    Take a look at this http://gamesalad.com/ontheappstore/3337 I think it might be abut what you are wanting
  • dashnevadadashnevada Member Posts: 58
    tenrdrmer said:
    Take a look at this http://gamesalad.com/ontheappstore/3337 I think it might be abut what you are wanting

    Thanks a lot tenrdrmer.. I can actually make it work with this template... Many many thanks. :)
  • dashnevadadashnevada Member Posts: 58
    the line doesn't really interpolate.. but if that a big hassle I just can do something like this.
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    yeah basically appears but it happens so fast it looks like its shooting out. You could probably modify the expressions to give a better effect but that thing is pretty good.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    It's certainly nicely done though; possibly based on one of Joe's (Firemaplegames) excellent templates. It could be amended for what you are after if you know where it could be downloaded from. (I can't seem to download any of those Game uploads any more; don't know about anyone else).

    I'll hang fire on working out my solution until later, if you can't find it.

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    You have to search the name of the demo in the "new" tab on GameSalad. if its set to downloadable it will show up. Then double click the icon that pops up.

    edit:
    Oh and its by ORBZ from quite a while back so I have a feeling its original to him.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    tenrdrmer said:
    You have to search the name of the demo in the "new" tab on GameSalad. if its set to downloadable it will show up. Then double click the icon that pops up.

    Ah, of course, I'd forgotten about that! Thanks tenrdrmer.

    See, I sort of agreed with you!

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

Sign In or Register to comment.