[SOLVED] set x on screen

bobbyck

  • *
  • Posts: 124
Hi,

I'm trying to set an actor to the right hand side of the screen.

I'm using :

set (X on screen) to (screen width) - (width of actor) for (actor)

However, its not setting it to the right hand side of screen, but rather to the camera center.

screen width is indeed returning the correct screen width (320px). I used  "draw (screen width)" to confirm that the output was correct.

Am i doing something wrong here? Is there another way to do this?

thanks.

« Last Edit: November 22, 2017, 10:47:47 am by bobbyck »


bobbyck

  • *
  • Posts: 124


The code.



The large white outline just to the right of camera center. (The black box is just a placeholder showing where camera center is).

I have other actors set to use the exact same code but use "set  y onscreen" instead of "set  x onscreen" and they work fine.

« Last Edit: November 22, 2017, 08:27:34 am by bobbyck »

colburt187

  • *
  • Posts: 2394
Use set x of self instead of x (on screen)

bobbyck

  • *
  • Posts: 124
Hi Colburt,

I've tried that. It's placing it to 320 in the scene and not 320 on the screen. I'm guessing something is just not working right here.

Is there any other way to achieve the alignment to right?

SadiQ

  • Posts: 1781
Set x of self to scene width(pixels) - width of self ?
Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

colburt187

  • *
  • Posts: 2394
I use that code all the time, although I normally have it in the actor events. Do you have the actor as always active
Ah actually, I normally anchor the actor to the screen.


bobbyck

  • *
  • Posts: 124
I couldn't get it to work that way, so I used the anchor to screen. It's still not working perfectly (offset by about 15 pixels on some scales), but close enough.

Thanks for the help, completely forgot about anchor :)