Upside down

OK I've looked through the forums and I've seen questions close to this but not this specific one.

I have a button on the bottom left that when clicked, spawns actors at the top of the screen. They span off the screen on the left or right side randomly and then slide in screen across to the opposite side.

So when the actor spawns on the left and moves to the right... it's good. But when it spawns on the right and moves to the left, the actor is upside down. I can't figure out how to fix this. I've tried rotate to angle, and some other things but nothing has worked so far.

Any ideas?

Thanks.

Best Answer

  • SocksSocks London, UK.Posts: 12,822
    edited January 2013 Accepted Answer
    I'm not trying to start an argument. I'm just saying one should be efficient. If you are trying to argue with that... hmmm.
    Life's always good when you get to write your own reviews. :)

    Like I say, if you feel the suggestions are overly complex I wouldn't give up on your turning an actor upside down as a way of changing direction, you just need to work out a way of turning the upside down actor's image back the right way - I've given you a suggestion in my post above.
    I tried your idea "1024 minus self position". Although it makes sense, it dosen't seem to work, at least not in this situation.
    It should work fine, you've probably not implemented it properly, if you post your rules I'll take a look at where you might be going wrong.

Answers

  • SocksSocks London, UK.Member Posts: 12,822
    edited January 2013
    Questions like this make the reader do all the work, you have infront of you the rules that cause the actor to behave this way, anyone trying to help out has nothing other than a description of the result of these rules - so the person trying to help has to go through a process of guessing what these rules might be and how they might be causing the issues you describe.

    This is not aimed at you per se, you get so many questions framed in this way - and they simply defy logic from what I can see - they may as well read: 'I have created some rules that produce a certain result, you don't get to see these rules, but I will describe the result and then ask you to guess what the rules are and then ask you to suggest a solution'.

    Or put another way:

    Hey, I've just done a calculation and I keep getting 17 as the result but I was expecting 12, anyone know why ?

    [/Rant Over]

    8-X
  • belottebelotte Member Posts: 25
    Hello Socks.
    You are absolutely right. I don't know why I didn't think of that.

    OK so here are the rules I am using:

    I have a few custom attributes:
    cloudNum: integer 0
    randDirection: integer 0

    On the button instance:
    *Actor receives touch is pressed and cloudNum < 3
    *Change attribute randDirection to random(1,6)
    *When attribute randDirection < 5
    *Spawn actor:direction 0, relative to scene, position -35x 295y relative to scene
    Otherwise
    * Spawn actor:direction 180, relative to scene, position 580x 295y relative to scene
    *Change Attribute cloudNum to cloudNum+1

    On the actor prototype:
    Change Velocity: direction 0, relative to actor, speed 30

    So... any ideas?
  • SocksSocks London, UK.Member Posts: 12,822
    edited January 2013
    Hello Socks.
    You are absolutely right. I don't know why I didn't think of that.
    It's not just you, you see it time and time again here on the forums, questions essentially about a set of rules are asked with, at best, a few scant clues about what those rules might be, it can often render simple questions very difficult or even impossible to answer.
    OK so here are the rules I am using . . .
    :)>-

    Great! I'll take a look in a bit, not at my computer right now (on iPad).
  • SocksSocks London, UK.Member Posts: 12,822
    edited January 2013


    Otherwise
    * Spawn actor:direction 180, relative to scene, position 580x 295y relative to scene . . . .


    Basically you are turning the spawned actor upside down.

    Try this:

    Spawn actor:direction 0, relative to scene, position 580x 295y relative to scene . . .
  • belottebelotte Member Posts: 25
    Hello socks.
    Yes I know it's turning it upside down. But if spawn an actor off screen on the right, and the direction is set to 0 (facing the right), then it never comes on stage.

    So how would I spawn an actor on the right and have it move to the left with out flipping it?

    Direction, should be just that, direction; not the orientation of the actor.
  • SocksSocks London, UK.Member Posts: 12,822
    edited January 2013
    if spawn an actor off screen on the right, and the direction is set to 0 (facing the right), then it never comes on stage.
    Just for clarity, '0' is not facing the right, an actor has no 'facing' value, spatially it only has a location, size and rotation.
    So how would I spawn an actor on the right and have it move to the left with out flipping it?
    The question is really: 'how would I move an actor to the left' - you can move an actor in whichever way you want, whichever way suits your needs (interpolate, move, move to, accelerate, constrain . . etc)
    Direction, should be just that, direction; not the orientation of the actor.
    'Should' :)
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited January 2013

    Hi @belotte

    To clarify even more what @Socks said, and what's been discussed so far:

    You're correct in saying that the direction value in a Spawn Actor behaviour is the orientation of the actor - the rotation direction - and not the movement direction. (Perhaps it should be relabelled, but its always been that, so I guess as long as you know what it does, its OK...)

    Anyhow, so as not to rotate the spawned actor, just keep it to 0 as has been said. And to affect the direction of the spawned actor, use the Direction in your Change velocity Behaviour which does affect the actual direction - as an attribute if you wanted - where 0 is right, 180 left, 270 down and 90 up (as you know).

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

  • belottebelotte Member Posts: 25
    thanks for all the input.

    The problem with that is I have the prototype with a generic speed of 30 with no direction other than along the x axis.

    what I wanted to do was have one proto type with the base speed and no direction. Then one rule that would either spawn the actor randomly on either the left or the right, and go in the proper direction based on that. The way you are suggesting mean I have to have 2 prototypes, one for each direction. This increases coding, complexity, and file size. That's not good.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited January 2013
    ....The way you are suggesting mean I have to have 2 prototypes, one for each direction. This increases coding, complexity, and file size. That's not good.
    In that case, use the Telepathy Behaviour... ;-)

    By the way, I didn't suggest having two prototypes, although that's one way to do it, but it seems that way would upset you to do.

    Why not use a boolean or even an integer "switch" with two sets of rules in your one prototype actor's rules that's to be spawned; one for moving it left to right, one for right to left.

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

  • belottebelotte Member Posts: 25
    Now thats a good answer. I don't know why I didn't think of that. You are a klever one.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited January 2013
    Now thats a good answer.
    You're welcome, @belotte :-)
    You are a klever one.
    Sshh, I pretend....I've fooled people so far... B-) :-$ :-) (But thank you for saying!)

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

  • SocksSocks London, UK.Member Posts: 12,822
    edited January 2013
    The way you are suggesting mean I have to have 2 prototypes, one for each direction. This increases coding, complexity, and file size. That's not good.
    Increase in coding ? . . . . emmm . . . would that be having to turn a little graphic wheel 180° ? . . . what can I say, life is cruel and some people in this life are born to suffer. :))

    Increase in complexity ? . . . . I'm guessing that extra actor will make your project an impenetrable mystery.

    Increase in file size ? . . . . one extra actor uses up a few kilobytes.

    But you can avoid this unbearable workload 8-X by having your actors (all of them, regardless of where the are spawned) share a common move, I wouldn't tie yourself to the idea that actors are like wind up toys and only move in one direction regardless of where they are placed (the corollary being a need to turn them upside down to get them to move in the opposite direction).


    For example (on a landscape iPad) a single common rule that interpolates an actor's position to [1024 minus self position] would see actors spawned at 0 move right to 1024 (1024 - 0 = 1024) . . . and actors spawned at 1024 move left to 0 (1024 - 1024 = 0).
  • belottebelotte Member Posts: 25
    Hmmm.

    Well Socks. That last trick may be the one, I'll have to try it.

    In regards to the excess code, etc complaints... I've worked in the IT market for over 17 years. One should always strive for clean and simple code. On one actor maybe not a big deal... but if the only solution is a complicated one, and it has to be done multiple times... then you start to have problems.
  • SocksSocks London, UK.Member Posts: 12,822
    edited January 2013
    One should always strive for clean and simple code. On one actor maybe not a big deal... but if the only solution is a complicated one, and it has to be done multiple times... then you start to have problems.
    No one has suggested a complicated solution.

    But if you feel these suggestions are overly complicated then I'd carry on with the idea of the actor having a fixed unidirectional movement and flipping it over as your preferred method of changing direction (the wind up toy approach) - you just need to work out a way of flipping its image - you might be able to unlock the actor in the scene and flip its image in graphics.attributes?.

    [EDIT - just checked, yes you can unlock the actor in the scene and use flip horizontal and flip vertical to correct the orientation of the rotated actor, maybe this is a happy compromise as it allows you to avoid any complicated coding]
  • belottebelotte Member Posts: 25
    I'm not trying to start an argument. I'm just saying one should be efficient. If you are trying to argue with that... hmmm.

    :)
    In any even. I tried your idea "1024 minus self position". Although it makes sense, it dosen't seem to work, at least not in this situation.

    Sincerely though, thank you for the ideas though! It's good to get a diffrent view on things.
  • belottebelotte Member Posts: 25
    OK so the rule I have is as follows:
    *Interpolate
    *From self.Position.X to 580- self.Position.X
    Duration: 30, Function: Linear

    I tried this with "move" and "move to" as well.
  • belottebelotte Member Posts: 25
    edited January 2013
    Hey there @gyroscope.

    I actually had created a "switch" of sorts. I used random (1,6).

    if < 5 go left otherwise go right.

    But that's the rule that's not working.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited January 2013

    Hi @belotte I've done a little test, hopefully it'll be helpful for you. (Replace the change velocity behaviours with interpolate behaviours, if you want):

    https://dl.dropbox.com/u/14060718/Rand spawn LorR.gameproj.zip

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

  • SocksSocks London, UK.Member Posts: 12,822
    edited January 2013
    OK so the rule I have is as follows:
    *Interpolate
    *From self.Position.X to 580- self.Position.X
    Duration: 30, Function: Linear

    I tried this with "move" and "move to" as well.

    Link: http://www.mediafire.com/?c6ga9aogjagpmfr
  • belottebelotte Member Posts: 25
    Hey there.

    Well Socks and gyroscope... thanks for all your help. I am retarded though, I cant get either solution to work for me for some reason.

    In any event, thank you. You guys have been very gracious in your efforts.
  • SocksSocks London, UK.Member Posts: 12,822
    I cant get either solution to work for me for some reason.
    Did you check out the test project (above) I made for you ?
  • belottebelotte Member Posts: 25
    yes I did. I even tried copying the elements from your test. Both you and gyroscope were very gracious and did individual examples for me. I looked at both of them.
  • SocksSocks London, UK.Member Posts: 12,822
    yes I did. I even tried copying the elements from your test.
    But you couldn't get it to work ?
  • belottebelotte Member Posts: 25
    Nope. Obviously I'm doing something wrong. I've looked at yours and it makes sense and works. But when I do the same on mine... no go.
  • SocksSocks London, UK.Member Posts: 12,822
    Nope. Obviously I'm doing something wrong. I've looked at yours and it makes sense and works. But when I do the same on mine... no go.
    Did you make a self.attribute for the actor that moves ?

  • belottebelotte Member Posts: 25
    Ahhh. That's what I was missing. THANK YOU!!!!
Sign In or Register to comment.