[SOLVED] Newbie question about grid (x/y) positioning

rezaf

  • Posts: 5
I've created my first simple demo game.
It populates a map with "tile" actors that I can switch to a different terrain type.
I then put "unknown" actors on top of them that are black.
Finally, I  create a demo "player" actor that I want to move around, revealing the tiles that he "hits".
This all works.

But I have two issues:
First, how do I "store" a reference to the player actor. To experiment, I just make it after all the other actors and then can refer to it as "Last created actor", but that isn't very practical.
Surely there's a better way?


Second, when I try to spawn the player at x/y 0/0, it doesn't spawn at all.
When I set the coordinates to 1/0 or 0/1, it DOES appear, and does what it should, but the graphic is out of sync with the background tiles, it's a few pixels "off", so that he overlaps into the surrounding tiles. Why is that, and how do I fix it?

Thank you so much in advance.

PS: I apologize for the primitive nature of my first question here.

Edit: I toyed around some more, and when I slide the actor to 0:0, that works ... but just for a second, then it's relocated to 10:0'ish. Odd.

Edit2: I managed to find out about the reference issue myself, you can do it by creating an attribute under Getters. Works splendit.
_____
rezaf

« Last Edit: June 21, 2012, 11:09:52 pm by rezaf »

applaud

  • Posts: 370
Have you got any rules that kill/hide the actor when he reaches x=0 or y=0 ?

rezaf

  • Posts: 5
Not unless they are default behavior.

I thought that it might be somehow related to the default "physics" of the scene, like I wrote, manually moving the actor to 0/0 DOES work, but after half a second, it switches back.
_____
rezaf

Hectate

  • *
  • Posts: 4643
Perhaps it could be colliding with something there, do you have it set to collide with something (other than a sensor or region) that might be in that place?
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

rezaf

  • Posts: 5
Well, a collision probably IS occuring, since even though I put the player test unit on a different layer, the collision events are firing. However, they are not actually having an effect on any subsequent move, just the first one.
Can I tweak the game so a collision does NOT move the player unit in any way?

Thanks.
_____
rezaf

hansbe

  • Posts: 262
Can I tweak the game so a collision does NOT move the player unit in any way?

You can set the collision shape to be a sensor. Or you can remove the collision shape. Or you can disable physics alltogether.

rezaf

  • Posts: 5
It might be bad (beginner at work!), but I think I cannot remove physics - currently revealing the tiles works by detecting collisions with the "fog of war blocks".
Removing the collision box is also not possible for the same reason, as I understand it.

If it's not possible to have an actor not move when colliding, I'll probably have to think of another way to implement this. Is that the case?

Thanks.
_____
rezaf

hansbe

  • Posts: 262
Sorry, I ended up not answering your question. You can turn off 'movement'. Just check the different actor settings tabs, there are many options.

rezaf

  • Posts: 5
I solved the issue by setting EVERY actor to sensor (thanks for the tip!), not just the player.
Next issue I had was that, for whatever reason, the slide-to command sometimes puts the player a few pixels off to where I wanted it to go.
So I switched to directly setting the x or y coordinate, which works better, but doesn't give the "movement" vibe. But this is only experimentation anyway.
Then I made the player actor's collision box 50% bigger, so it'd reveal all the "fog of war blocks" around him.
That all works fine now.

It's only a very barebone implementation - I'll try to scale up next time, but everyone has to start somewhere, right?
In any event, the "prototype" now does what I wanted it to do - thanks everyone for your help.
_____
rezaf