Please login or register.

Login with username, password and session length
Advanced search  

News:

For WME related articles and tutorials visit WME Resource Center.

Author Topic: GetAttachment-Problem ?  (Read 2808 times)

0 Members and 1 Guest are viewing this topic.

Kapryagos

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 11
    • View Profile
    • casummer.eu
GetAttachment-Problem ?
« on: October 17, 2010, 02:41:28 AM »

Hello. I want to attach a head to my actor, separately from the body. But in this case, I'm talking about a 2D-Actor.
So I used "AddAttachment" to put an entity onto my actor (named Honda)...
Code: [Select]
ENTITY
{
  SPRITE = "actors/Honda/hondahead01.png"
}

So far it worked, but when I try to manipulate that attachment, my code does nothing, and neither do I get any informative debug-log.
(The following code is meant to change the attached file to fit the actor's direction.)
Code: [Select]
this.AddAttachment("actors/Honda/hondahead01.entity", true, -45, -384);
var Hondahead = this.GetAttachment(0);

while(true) {
if(this.Direction=="DI_LEFT") {
Hondahead.SetSprite("actors/Honda/hondahead01.png");
}
if(this.Direction=="DI_RIGHT") {
Hondahead.SetSprite("actors/Honda/hondahead02.png");
}
Sleep(20);
}

I have tried several variations of this code, changing the "DI_LEFT" to "LEFT" etc., calling the attachment's filename instead of an index number, and other details.
But since I won't get any failure messages in the log I don't know what is wrong and I must suppose that there several faults in it, which increases my confusion.
So I beg for help, please!
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: GetAttachment-Problem ?
« Reply #1 on: October 17, 2010, 08:24:28 AM »

DI_LEFT etc. are constants, not strings. So the proper syntax is:

if (this.Direction == DI_LEFT) ...
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Kapryagos

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 11
    • View Profile
    • casummer.eu
Re: GetAttachment-Problem ?
« Reply #2 on: October 17, 2010, 03:37:39 PM »

Worked -- thank you! :)
Logged
 

Page created in 0.048 seconds with 24 queries.