Please login or register.

Login with username, password and session length
Advanced search  


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

Author Topic: Interactive theora entities - tutorial  (Read 4471 times)

0 Members and 1 Guest are viewing this topic.


  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Interactive theora entities - tutorial
« on: January 10, 2010, 09:22:20 PM »

Hi muties,

this one will be short but for those of you who are using theora entities in your scripts and thought they are not interactive, I provide the following trick, how to mend this.

Logic behind the following code is, that WME now supports creating own regions even if there's none. So we'll creating bounding region ourselves manually.

We'll presume your theora is square 128x128 points, other shapes are just a matter of using more region points.
First in Scene Edit create an empty entity and call it test, then in scene_init.script type something like this:

Code: WME Script
  1. var ent = Scene.GetNode("test");
  2. ent.PlayTheora("your ogv file goes here",true,"your mask goes here"); // so our theora is playing now!
  4. ent.CreateRegion(); //we create a new region so our entity will become interactive
  6. var region = ent.Region;
  8. region.AddPoint(ent.X, ent.Y);
  9. region.AddPoint(ent.X, ent.Y + 128);
  10. region.AddPoint(ent.X + 128, ent.Y + 128);
  11. region.AddPoint(ent.X + 128, ent.Y);
  12. ent.Interactive = true;

Piece of cake, no? Now you can easily click your theora entity.

But wait what if you want to move it around on the screen? Simply update the region nodes based on current theora position!

Code: WME Script
  1. var ent = Scene.GetNode("test");
  2. var region = ent.Region;
  3. region.SetPoint(0,ent.X, ent.Y);
  4. region.SetPoint(1,ent.X, ent.Y + 128);
  5. region.SetPoint(2,ent.X + 128, ent.Y + 128);
  6. region.SetPoint(3,ent.X + 128, ent.Y);

That's all folks. Hope you find it as useful as I did for my game. :)
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Page created in 0.027 seconds with 20 queries.