snapping sprite to another sprites image point

This forum is currently in read-only mode.
From the Asset Store
Connect the dots in the correct order and draw happy animals!
  • I've added an image point called righthand to my hero sprite's animations, and I have a sword sprite. I want to constantly set the swords position to the hero's imagepoint. I tried:

    <img src="http://dl.dropbox.com/u/19777553/forum%20images/code1.jpg">

    And the sword sprite (sprite 2) is nowhere to be found. It disappears from the screen to who knows where. Just wondering if I am using this action correctly, or if I have to find another way.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Am I reading right or did you set the position of the sprite2 to the image point, thats also on sprite2? If you have a hero, put the sword, to the heroes image point.

    Allways -> Sprite2: set position to object Hero (image point "righthand")

    Of course, you have to set that imagepoint at the hero before.

  • hehe oops.

    Also you might not need send to front as an always event.

  • Argh, actually that was just something stupid I did while rewriting the event to make a screenshot. It's not working even when I scripted it

    Allways -> Sprite2: set position to object Hero (image point "righthand")

    Am I correct then that I should be getting the desired result?

  • Dunno what you are doing wrong.

    Here my megabasic example for that xD

    http://dl.dropbox.com/u/26932498/righthand.cap

    Don't complain about the graphics <.< I was lazy...

  • Pretty much what I'm doing here, which is very frustrating. I must have something going on elsewhere that is messing with things.

    Edit: Figured it out in the debug. Somehow there are two instances of the Hero sprite. The challenge is finding the dupe.

    Edit 2: Construct is pulling an extra copy from a layout that I haven't loaded. I didn't realize it would load instances of sprites from layouts other than the one in use.

  • If you still have problems. Post the .cap.

    Good luck with your game.

    edit: Oh man, you post faster edits than I can blink lol. Hm, I only know, global objects will pass through layouts. Maybe newt has an answer

  • Figured it out!

    I have an event sheet I've been including in new layouts with the hero movement script. I guess that event sheet points to a particular instance of the hero and pulls that instance onto the new layouts. In this case the hero was pulled into the new layout offscreen and the sword was snapping to it...

    Thanks for all your help!

    Edit: Yeah it is global, that was part of it I now realize.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)