Please login or register.

Login with username, password and session length
Advanced search  

News:

Forum rules - please read before posting, it can save you a lot of time.

Author Topic: Change Scene Scales Dynamically  (Read 3243 times)

0 Members and 1 Guest are viewing this topic.

donamin

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 27
    • View Profile
Change Scene Scales Dynamically
« on: March 30, 2013, 11:25:50 AM »

hello guys.
I need to change scales of a scene using code. is there anyway to do that?
thanx
Logged

2.0

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 217
    • View Profile
Re: Change Scene Scales Dynamically
« Reply #1 on: April 01, 2013, 08:22:49 AM »

Try to use something like this.

Code: WME Script
  1. var Scale = 50;
  2. var Layer = Scene.MainLayer;
  3.  
  4. for (var i = 0; i<Layer.NumNodes; i=i+1)
  5. {
  6.   var Node = Layer.GetNode(i);
  7.   Node.Scalable = 0;
  8.   Node.Scale = Scale;
  9.   // Next 2 strings - to change node's coordinates in correspond with changing scene scales
  10.   Node.X = Node.X*Scale/100;
  11.   Node.Y = Node.Y*Scale/100;
  12. }

You also may trying to use Scale Levels (in editor), but it has not changes coordinates of entities. To change it you may try to use Scene.GetScaleAt(X, Y) method.
I.e.

Code: WME Script
  1. Node.X = Node.X * Scene.GetScaleAt(Node.X, Node.Y)/100;
  2. Node.Y = Node.Y * Scene.GetScaleAt(Node.X, Node.Y)/100;

PS. Examples are not checked, try to do this manually :)

hello guys.
I need to change scales of a scene using code. is there anyway to do that?
thanx
Logged

donamin

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 27
    • View Profile
Re: Change Scene Scales Dynamically
« Reply #2 on: April 03, 2013, 07:50:07 AM »

thanx
i tried something like this, but it doesn't work.
(off-by-1-frame problem happens actually)
it seems we can't change scene scale bars directly.
Logged

2.0

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 217
    • View Profile
Re: Change Scene Scales Dynamically
« Reply #3 on: April 03, 2013, 09:00:08 AM »

Need to change

Code: WME Script
  1. Node.Scalable = 0;

to

Code: WME Script
  1. Node.Scalable = true;
Logged

donamin

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 27
    • View Profile
Re: Change Scene Scales Dynamically
« Reply #4 on: April 04, 2013, 06:04:36 AM »

yeah i tested that too.
for nodes other than actor it's fine, but not for actor.
when actor is walking in y axis, its scale is being updated by 1 frame delay.
Logged

2.0

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 217
    • View Profile
Re: Change Scene Scales Dynamically
« Reply #5 on: April 04, 2013, 01:33:20 PM »

But what if:

Code: WME Script
  1. for (var i = 0; i<Layer.NumNodes; i=i+1)
  2. {
  3.   var Node = Layer.GetNode(i);
  4.   Node.Scalable = true;
  5.   Node.Scale = Scale;
  6.   // Next 2 strings - to change node's coordinates in correspond with changing scene scales
  7.   Node.X = Node.X*Scale/100;
  8.   Node.Y = Node.Y*Scale/100;
  9.  
  10.   Actor.Scalable = true; //means that Actor is your Actor variable
  11.   Actor.Scale = Scale;
  12.   Actor.X = Actor.X*Scale/100;
  13.   Actor.Y = Actor.Y*Scale/100;
  14. }

?

yeah i tested that too.
for nodes other than actor it's fine, but not for actor.
when actor is walking in y axis, its scale is being updated by 1 frame delay.
Logged
 

Page created in 0.053 seconds with 21 queries.