change image by direction=...

wouterwouter Member Posts: 174
edited November -1 in Working with GS (Mac)
hi guys,
question:
by a direction of for example 0,2 the image must change to image_1
by a direction of for example 0,4 the image must change to image_2
etc.

i can do this with
rule:
when attribute game.direction = 0,2{
change image to image_1
}
otherwise{
rule
when attribute game.direction = 0,4{
etc.

only, the animation have a lot (17) of frames... this makes gamesalad very slow...
can i do this faster???

wouter

Comments

  • RHRH Member Posts: 1,079
    Can game.direction only = 0.2 or 0.4 etc? If so change the image names to 0.2, 0.4, 0.6 etc and constrain self.image to game.direction..".png"
  • wouterwouter Member Posts: 174
    no the direction = (game.x1-self.position.X)/(game.Y1-self.position.Y) (and game.x1 and game.y2 are the self.position.X and self.Position.Y of the loop before).
    so it can be all directions...
  • RHRH Member Posts: 1,079
    I think I posted this in your other thread, but try constrain attribute self.image to ceil((game.direction*10)/2)..".png" and rename the images 1,2,3,4 etc...
  • wouterwouter Member Posts: 174
    that sounds like a solution! thanks!
  • wouterwouter Member Posts: 174
    i did this:
    constain attribute:
    self.Image to ceil(( game.direction real *10)2) game.up game.>evenwichtinteger ".png"

    game.direction real = direction in decimal. game.up is up=2 and down=1
    and game.>evenwichtinteger = 1 above balance and 0 under blance. (sinus function)

    i have images called 110, 111, 120,121, 210,211,220,221,310,311,320,321,410,411,420,421,510,511,520,611. (all .png)

    but, get no images... what do i wrong?

    wouter
  • wouterwouter Member Posts: 174
    oh and whats ceil(x)?
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    ceil rounds up to the nearest whole number. Its the opposite of floor which rounds down
  • wouterwouter Member Posts: 174
    mmm and is there also a way to rounds up or down on the decimal number (0.1, 0.2, 0.3 etc).

    edit:
    (doesn't matter in this case by the way;)
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    not quitw sure i understand. the whole point of rounding up or down is to get to a whole number, so rounding to a decimal isnt really rounding. What do u want to do, you want it to go to the next decimal up or something?

    also if u didnt know you can use linear motion to determine direction and you can change images off that

    if motion linear x is > 0 your going right, if its < 0 your going left
    if motion linear y is >0 you moving up, and if its < 0 your goign down
  • wouterwouter Member Posts: 174
    yeah i know but its a sin, and both sites (up down) must be animated the up and down can be different so thats the reason why i calculate the direction;)
    if the direction comes close to 0 you are almost by an maximum or minimum and the animation is also different if it's by a maximum or minimum so that's the reason why i used above or under balance (=evenwicht in dutch^^;) and up...

    so i don't think i can use motion linear x or y in this case;)
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    ahh i see. You are indeed correct. If your using sin in a constrain for the wave moment it wont give u a linear motion
  • wouterwouter Member Posts: 174
    yeah;)

    only there's only a withe box so he didn't show images...
    what do i wrong... xD

    game direction is usually around -1,0,1 and if you move the sin it has tops of around 6 and -6..
    so it's logic that he doesn't show images above 1.2 (direction) (6*2/10) but under he doesn't either! (in the area of -1.2 to 1.2).....
  • wouterwouter Member Posts: 174
    mmm the images that goes down must have a - before (direction is negative), but the positive direction images doesn't show either...
  • wouterwouter Member Posts: 174
    and if i do this:
    ceil(( game.direction real *10)/2) + game.up + game.>evenwichtinteger ".png"
    the actor don't move?!

    ah even if i do self.Image to 111.png there happened nothing... (only a white block)... only why xD

    edit2
    this is because it must be "111.png"
    only if i do this:
    "ceil(( game.direction real *10)/2) game.up game.>evenwichtinteger ".png""
    or:
    "ceil(( game.direction real *10)/2) game.up game.>evenwichtinteger .png"



    this doesn't also work:

    "ceil(( game.direction real *10)/2) game.up game.>evenwichtinteger ".png

    this is frustrating...
  • wouterwouter Member Posts: 174
    bump^^ anyone??
  • RHRH Member Posts: 1,079
    The formula I gave you at the top definitely works if you name your images 1.png,2.png,3.png,4.png etc and constrain self.image on the actor you want to display the image to exactly:

    ceil(( game.direction *10)/2)..".png"

    Including the ..".png"
  • wouterwouter Member Posts: 174
    i have this:

    ceil(( game.direction real *10)/2) game.up game.>evenwichtinteger ..".png"

    and doesn't work...
    i have images called 110, 111, 120,121, 210,211,220,221,310,311,320,321,410,411,420,421,510,511,520,611. (all .png)

    up is 2 if goes up and one if goes down
    game.>evenwichtinteger is 1 if above the balance and 0 under the balance...
    direction is usual +- around -1,0,1 and with controls it can reach 6..
  • wouterwouter Member Posts: 174
    Bump
    Anyone??
  • wouterwouter Member Posts: 174
    what does the .. mean?
    in this tread: http://gamesalad.com/forums/topic.php?id=24031
    they are using more .. (... xD)
  • wouterwouter Member Posts: 174
    ah .. is that there follows another thing isn't it?
    only going up is good (only the animation not jet xD), but going down is a white block so an attribute is wrong but it showed something!!!:D
  • RHRH Member Posts: 1,079
    game.up game.>evenwichtinteger

    why have you put that in there?
  • wouterwouter Member Posts: 174
    yeah going down is negative and i forgot the - ^^

    lol i'm so happy i find out after 2 days...:D
  • wouterwouter Member Posts: 174
    wouter said:
    yeah i know but its a sin, and both sites (up down) must be animated the up and down can be different so thats the reason why i calculate the direction;)
    if the direction comes close to 0 you are almost by an maximum or minimum and the animation is also different if it's by a maximum or minimum so that's the reason why i used above or under balance (=evenwicht in dutch^^;) and up...

    so i don't think i can use motion linear x or y in this case;)

    thats the reason;)
  • wouterwouter Member Posts: 174
    ok now i have a minimum and a maximum top, so i think:
    if direction=0{
    if max then image_max
    if min then image_min
    }
    otherwise{
    constrain attribute self.image to ....
    }

    only... i have not for every direction an image so is there a way to do if image exist then image... otherwise keep image??

    wouter
  • RHRH Member Posts: 1,079
    So the up and down set of images are different? Putting game.up game.>evenwichtinteger in the formula will only muck it up I would imagine. If i now understand correctly what you want is...

    rule that when going up is true:
    constrain attribute self.image to: "up"..ceil(( game.direction *10)/2)..".png"

    OTHERWISE

    constrain attribute self.image to: "down"..ceil(( game.direction *10)/2)..".png"

    Name your images up1.png, up2.png, up3.png etc for all the images in the up animation and down1.png, down2.png, down3.png etc for images in the down animation
  • wouterwouter Member Posts: 174
    yeah i understand^^ i will change that;)

    only if the image doesn't exist don't change him... how can i do that?
    (oh and some images resize in my animation... ugly:@ xD so i have to make al the images the same size... (and some will have more alpha layer then others..)
  • wouterwouter Member Posts: 174
    oh and of cource i need if it is under the blance or not (because on both sides the direction slows down;)
  • wouterwouter Member Posts: 174
    or have i to copy every image and rename it until the next good direction (only i then have 75+ images to load (and there are 22)...
  • wouterwouter Member Posts: 174
    maybe i have to check all images of the image change exist (can you make arrays in gamesalad??)
Sign In or Register to comment.