[SOLVED] Is there a better way to do this?

Uuemaich

  • Posts: 52
I tried searching the forums before posting this, but I didn't know what to search for, haha.

I know there's a better way to do this, but I don't know what that is. I made an achievement page for the player to go to so they can check what they've gotten so far. Whenever the arrow actor is pointing to a specific place, it'll display text at the bottom about the achievement. It's working how I want it to, but so far I've only put it in 6 places, and the design mode is lagging (obviously), and I need to make 18 places in total.

How would I go about doing this more efficiently?

Thanks!

« Last Edit: April 04, 2012, 08:41:26 pm by Uuemaich »

IAP

  • Posts: 33
I don't know how to do it in stencylworks (the current version), but in stencyl2 you can make a costume code block, in witch you put all the repetitive tasks and can give it parameters. This will make your design 5 times smaller..
Sorry for my English, it's not my first language :)

Uuemaich

  • Posts: 52
Oh my gosh, awesome. I was going to try to upgrade to 2.0 later today, so that is very good news! I'll come back later and post about what happened!

Thanks!

Nomosoft

  • Posts: 122
If (right was pressed) {
  Move arrow 32 pixels to the right
  If arrow x position is now > width of screen (or x of last achievement icon) {
    Move arrow back to 32 (or whatever the first x-position is) and move arrow down 96 pixels (or whatever number is correct)
  }
  If arrow y position is now > bottom of screen (or y of bottom achievement row) {
    Set arrow y to y of top row
  }
}

Same thing for other arrow keys, just move the actor up, down, left, or right the appropriate number of pixels and check to see if he needs to wrap around to the next row/column.

Edit: In fact, you could just move the arrow on keypress and do all the position checking and row/column wrapping at once in its own block instead of putting it inside each keypress block.

Uuemaich

  • Posts: 52
Again, awesome! I'll try messing around with that in a little bit.

Thanks!

Uuemaich

  • Posts: 52
If (right was pressed) {
  Move arrow 32 pixels to the right
  If arrow x position is now > width of screen (or x of last achievement icon) {
    Move arrow back to 32 (or whatever the first x-position is) and move arrow down 96 pixels (or whatever number is correct)
  }
  If arrow y position is now > bottom of screen (or y of bottom achievement row) {
    Set arrow y to y of top row
  }
}

Same thing for other arrow keys, just move the actor up, down, left, or right the appropriate number of pixels and check to see if he needs to wrap around to the next row/column.

Edit: In fact, you could just move the arrow on keypress and do all the position checking and row/column wrapping at once in its own block instead of putting it inside each keypress block.

Thank you, sir! This worked like a charm and was super easy to set up!

Thanks again!

Nomosoft

  • Posts: 122
If (right was pressed) {
  Move arrow 32 pixels to the right
  If arrow x position is now > width of screen (or x of last achievement icon) {
    Move arrow back to 32 (or whatever the first x-position is) and move arrow down 96 pixels (or whatever number is correct)
  }
  If arrow y position is now > bottom of screen (or y of bottom achievement row) {
    Set arrow y to y of top row
  }
}

Same thing for other arrow keys, just move the actor up, down, left, or right the appropriate number of pixels and check to see if he needs to wrap around to the next row/column.

Edit: In fact, you could just move the arrow on keypress and do all the position checking and row/column wrapping at once in its own block instead of putting it inside each keypress block.

Thank you, sir! This worked like a charm and was super easy to set up!

Thanks again!

You're welcome, I'm glad I was able to help.