Author Topic: how to make the xscale from an object change to the xscale from the kid?  (Read 1297 times)

l3agu32

  • Wannabe
  • Posts: 22
  • OS:
  • Windows 8.1/Server 2012 Windows 8.1/Server 2012
  • Browser:
  • Chrome 48.0.2564.116 Chrome 48.0.2564.116
    • View Profile
  • Playstyle: Keyboard
I attached an object to the kid and I want to make this objects' xscale change always that the kid's xscale changes.
I put the codes in the step event of the object. The kid's object is named objPlayer.
The first code I tried was this one: image_xscale=objPlayer.image_xscale
The other code I tried was: if objPlayer.image_xscale=-1{image_xscale=-1}else{image_xscale=1}
I really don't know if the dots are needed or if the code has to be in the step event. I would appreciate some help, thank you.

patrickgh3

  • Spike Dodger
  • Posts: 169
  • stay optimistic! :D
  • OS:
  • Windows 10 Windows 10
  • Browser:
  • Firefox 44.0 Firefox 44.0
    • View Profile
    • Github
  • Playstyle: Keyboard
Re: how to make the xscale from an object change to the xscale from the kid?
« Reply #1 on: February 21, 2016, 05:51:29 PM »
Your code would work in the 8.1 engines, but not the studio engines, which I assume you're using. For some reason changing the player's image_xscale in studio messes up the physics. So instead, the engines store that xscale variable somewhere else, and manually draw the player with that xscale. In Yoyo's engine the variable is "player.xScale", and in previous versions it was "global.player_xscale". So yeah, your first attempt is the right idea, just use the player's special xscale variable instead.

L4Vo5

  • Cherry Eater
  • Posts: 59
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Chrome 48.0.2564.116 Chrome 48.0.2564.116
    • View Profile
  • Playstyle: Keyboard
How does it mess with the physics? i'm making a game (not using any engine) and this sounds kinda worrying.
I have to admit, i still haven't beaten IWBTG