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: GetSprite problem  (Read 4527 times)

0 Members and 1 Guest are viewing this topic.

fireside

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 211
    • View Profile
GetSprite problem
« on: April 02, 2007, 09:47:13 AM »

I have two entities using the same sprites.  The following code should get the same results because the sprite path prints the same to the screen, but the first one says "equal" and the second one says "not equal".
 var ball = Scene.GetNode(varPark2.currentBall);
 Game.Msg(ball.GetSprite());
 var ballSprite = "entities\ballRed\sprites\ballClear.sprite";
 if (ball.GetSprite() != ballSprite)
 {Game.Msg("not equal");}
 if (ball.GetSprite() == ballSprite)
 {   Game.Msg("equal");}

I'm totally stumped on what could be wrong. I've clicked between the two entities in the editor and the sprites are exactly the same.
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: GetSprite problem
« Reply #1 on: April 02, 2007, 10:30:08 AM »

try Game.Msg(ball.GetSprite()); to see what's in the other one.
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

fireside

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 211
    • View Profile
Re: GetSprite problem
« Reply #2 on: April 02, 2007, 03:38:50 PM »

It's already reading what's in both of them.  It goes through once, then varPark2.currentBall gets changed to the other one and it again reads it to the screen.  I have it print out which ball entity it is, and it prints "ball1" and the sprite path, then it prints "ball2" and the sprite path.  Even though they have exactly the same sprite path printed to the screen, one shows equal and the next shows not equal. If it's comparing strings, then something is different about the two strings that are being returned.  Either that, or it's not comparing strings.

I found a work around for it.  If I set the sprite in scene.init, it works, even though I'm setting the sprite to the same thing that it's set for in the scene editor.
« Last Edit: April 02, 2007, 03:59:46 PM by fireside »
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: GetSprite problem
« Reply #3 on: April 02, 2007, 06:02:50 PM »

Perhaps those two filenames differ in case? ("filename" != "Filename")
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

fireside

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 211
    • View Profile
Re: GetSprite problem
« Reply #4 on: April 02, 2007, 08:09:16 PM »

That's what was happening.  When I pick up the sprite by clicking in the scene editor, it changes the name to all lower case letters, from ballClear.sprite to ballclear.sprite.  The first one had used SetSprite() in the scene init, but not the second one.  Why does it do that?
Logged

sharkbait

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 13
    • View Profile
Re: GetSprite problem
« Reply #5 on: April 03, 2007, 04:24:24 PM »

I have to agree that I find the lower-casing annoying. Sometimes I even end up opending the files via a text editor to correct the cases but obviously the changes get lost as soon as I use the related editors. Is there a reason for the change of case?
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: GetSprite problem
« Reply #6 on: April 03, 2007, 06:37:32 PM »

Well there are some internal reasons but I guess I can eliminate them (actually I just did, so expect the filename case to be preserved in the next wme release).
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

fireside

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 211
    • View Profile
Re: GetSprite problem
« Reply #7 on: April 04, 2007, 01:26:36 AM »

Good, thanks.  It's tough for me to name things in a different way.  I've been doing it that way for quite a while.
Logged
 

Page created in 0.032 seconds with 19 queries.