Please login or register.

Login with username, password and session length
Advanced search  

News:

This forum provides RSS feed. To query recent posts use this url. More...


Author Topic: Entity Position Now Fixed  (Read 2733 times)

0 Members and 1 Guest are viewing this topic.

eborr

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 196
    • View Profile
Entity Position Now Fixed
« on: May 27, 2014, 12:49:17 PM »

Hello

I have created an entity which is essentially a thought bubble. It derives it's coordinates from the actors position on the screen.

Now it works well in the foreground,  and appears in the correct position, however in the background it appears to at the below the actor, even though looking at the thing in the debugger the entities X  and   Y values seems to be correct.

Can anyone suggest the probably blatantly obvious mistake that I made. One thought is that it might be caused by the floor

Please see the code for the method below.

Code: [Select]
method thought(texti,soundfile)

{
Game.Interactive = false;
actor.Interactive = false;
var thinking = Scene.CreateEntity();
thinking.Scalable=false;
var actorscale = Scene.GetScaleAt(actor.X,actor.Y);

if (actor.X > (Game.ScreenWidth/2))
{ thinking.X = actor.X-200;
  thinking.SetSprite("interface\thought\thoughtright.png");
   if(actor.Direction==DI_LEFT)thinking.X = thinking.X -30;
 }
 else
  {     thinking.X = actor.X+25;
   if(actor.Direction==DI_LEFT)thinking.X = thinking.X -30;
thinking.SetSprite("interface\thought\thoughtleft.png");
   }


if ((actorscale >40) && (actorscale < 60))
   {
   thinking.Y = actor.Y - 100;
}
if ((actorscale >59) && (actorscale < 70))
   {
   thinking.Y = actor.Y - 150;
}
if ((actorscale >69) && (actorscale < 80))
   
   {thinking.Y = actor.Y - 380;
      }

if ((actorscale >79) && (actorscale < 90))
{thinking.Y = actor.Y - 400;
        }
if ((actorscale > 89) && (actorscale  <95))
   {thinking.Y = actor.Y - 430;
    }
  if (actorscale >94)
  {
   thinking.Y = actor.Y - 450;
    }
  var ypos;
var textlen = new String(texti);
if(textlen.Length < 20)  ypos = 80;
if((textlen.Length > 19) && (textlen.Length < 40)) ypos = 85;
if(textlen.Length >39) ypos = 95;

thinking.SetFont("fonts\admono12.font");
thinking.SubtitlesPosRelative;
thinking.SubtitlesWidth=100;
thinking.SubtitlesPosXCenter=true;
thinking.SubtitlesPosX=90;
thinking.SubtitlesPosY =ypos;
thinking.Talk(texti,soundfile);
while(thinking.IsTalking==true);
   {
    Game.Interactive=false;
     Sleep(20);
     }
Game.UnloadObject(thinking);
Game.Interactive = true;
actor.Interactive= true;

}

Just an additional thought, might this work better as a window than an entity. Switched it to an entity in a container in a window, this works, although it might just have been my imbecilic maths that was faulty.

« Last Edit: May 29, 2014, 12:00:57 PM by eborr »
Logged

piere

  • Supporter
  • Frequent poster
  • *
  • Karma: 4
  • Offline Offline
  • Posts: 301
  • Sorry for any bad english in my posts. Game on !
    • View Profile
Re: Entity Position Now Fixed
« Reply #1 on: May 30, 2014, 09:09:01 PM »

You would want to use the StickToRegion method on the bubble, so maybe make a "Bubble" region in your scene file, and make sure it is higher ranking than the default region so it images and stuff will appear on top of the original default region.
« Last Edit: May 30, 2014, 09:12:12 PM by piagent »
Logged
 

Page created in 0.022 seconds with 19 queries.