snapping sprite to another sprites image point

For questions about using Classic.

Post » Tue May 03, 2011 7:16 pm

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:

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.
B
3
G
1
Posts: 23
Reputation: 521

Post » Tue May 03, 2011 7:27 pm

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.
B
24
S
9
G
2
Posts: 294
Reputation: 3,160

Post » Tue May 03, 2011 7:42 pm

hehe oops.
Also you might not need send to front as an always event.
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Tue May 03, 2011 8:39 pm

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?
B
3
G
1
Posts: 23
Reputation: 521

Post » Tue May 03, 2011 8:51 pm

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... :lol:
B
24
S
9
G
2
Posts: 294
Reputation: 3,160

Post » Tue May 03, 2011 8:55 pm

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.
B
3
G
1
Posts: 23
Reputation: 521

Post » Tue May 03, 2011 9:02 pm

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 :?: :mrgreen:
B
24
S
9
G
2
Posts: 294
Reputation: 3,160

Post » Tue May 03, 2011 9:06 pm

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.
B
3
G
1
Posts: 23
Reputation: 521


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 5 guests