Changing actors width one specific direction?

Hello

How would I go about having a rule that changes the length of an actor but only increase in one direction.

I have the a rule called number.
When it is equal to 1 the actor needs to change it's width to 500 but only increase towards the right. Thanks

Comments

  • SocksSocks London, UK.Member Posts: 12,822
    edited January 2013
    A combination of changing position and changing width should do the trick.

    So to change an actor from 250 wide to 500 wide - and those extra 250 pixels of width only want to be added onto the right - would be achieved by doing the following . . .

    Change width from 250 to 500
    Change position X from current position to current position + 125

    Or to codify it a little more: any growth in width value needs to have half of that value added to the actor's X position.
  • ElfizmElfizm Member Posts: 489
    @socks

    Yeah that was my first experiment but i found it like a work around and was hoping there was a formula that could easily be used.

    In my line jumper clone game I have the line platform increase only on one side but it's based on magnitude self position and touch position of y and x. But in this game I don't have a touch value, I just need it to increase to a certain point.

    Thanks for the answer though :)
    But if there is a forumla I am all ears.
  • SocksSocks London, UK.Member Posts: 12,822

    But if there is a forumla I am all ears.
    ?

    The formula is in my post, as the actor becomes wider add half of that additional width onto the x position.
  • ElfizmElfizm Member Posts: 489
    @socks

    Yes you do but it requires two rules to complete, which in away is fine but was hoping for one rule,
    It also gets messy because I am currently doing it the same way you said and need attributes into it because the size depends on the users input. So there isn't any set size limit. Which also means I need to record the distance and minus if from current position ect. Alot of messying around that could be replaced by a forumla that makes the actor increase to what ever size needed in one way. That is if there such forumla or rule.
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    edited January 2013
    @Elfizm -- Socks did give you the general formula:
    Or to codify it a little more: any growth in width value needs to have half of that value added to the actor's X position.
    If you want to keep the left edge of an actor at 100 pixels, this translates to something like this:

    Constrain Attribute: self.Position.X To: 100 + self.Size.Width /2
  • SocksSocks London, UK.Member Posts: 12,822
    edited January 2013


    If you want to keep the left edge of an actor at 100 pixels, this translates to something like this:

    Constrain Attribute: self.Position.X To: 100 + self.Size.Width /2

    [Edit] Yes, that's essentially the rule for the x position in this scenario, coupled with a rule for the width gives us the solution.
  • ElfizmElfizm Member Posts: 489
    @RThurman
    Well I am not sure how to put that into content with the following:

    interpolate width to 600 in 1 second.

    But my actor x position is not a set value. It changes and I can not have it go self.position ect because logic tells me that won't work.

    So then from my guess is that I will need a way to somehow know a fraction of a second before the event happens to record it's initial position and use that in forumla. But then things get complicated because there is other variables that affects the actor as well and it's x position. Which is why I thought I might ask for a way to make it increase one way without messing with the x position being a major variable. I know either way it's going to change the x value but I don't want it to be based on the x position.
    But thank you for your help. I think I may need to rethink how I want this to happen and work around it.
  • SocksSocks London, UK.Member Posts: 12,822
    edited January 2013
    Good luck with this, hope you get a solution.
  • ElfizmElfizm Member Posts: 489
    What I meant is that I can't go interpolate self.position because it won't work. It has to be a non changing figure. Which is why i would have to have a recorded position before it started interpolate and use that. I just though there could be an easier more effieceint way, so changing the width my not be good but instead spawn images or something to create the same effect.
Sign In or Register to comment.