This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-09-23 17:16:24

tchan5158
New Scratcher
Registered: 2010-09-19
Posts: 25

Shield Lags Behind

Hello  smile

I have a Ship sprite and a Shield sprite set to always be at Ship's location, but the Shield sprite lags behind about 3-4 pixels the previous location when my ship is moving fast.  sad   I want it to be exactly the same position as the Ship at all times.

I used this for the Shield sprite:
[blocks]
<when green flag clicked>
<set[ ghost ]effect to( 60 )
<show>
<go to front>
<go back( 3 )layers>
<forever>
<go to[ MainShip ]
[/blocks]

Is it possible?  What should I change to make it work?  Thanks  big_smile

-Tommy

Offline

 

#2 2010-09-23 17:35:56

ScratchReallyROCKS
Scratcher
Registered: 2009-04-22
Posts: 1000+

Re: Shield Lags Behind

Unfortunately, this can't be fixed. There's about a 0.01 second delay between blocks, so it's always going to lag.


http://imageshack.us/a/img694/3806/sigmad.png

Offline

 

#3 2010-09-23 18:57:53

roger-
Scratcher
Registered: 2010-02-13
Posts: 100+

Re: Shield Lags Behind

here's one way to fix it.

after the movement script for the ship, add a broadcast.

in the script for the shield, do
when I receive[blah]
go to ship


Food is Fat. Fat is power.
        I am almighty.

Offline

 

#4 2010-09-24 04:37:19

tchan5158
New Scratcher
Registered: 2010-09-19
Posts: 25

Re: Shield Lags Behind

roger- wrote:

here's one way to fix it.

after the movement script for the ship, add a broadcast.

in the script for the shield, do
when I receive[blah]
go to ship

ahhh thank you very much!  big_smile   big_smile   big_smile

Now I can add ship attachments and all sorts of stuff ^^

Offline

 

#5 2010-09-24 13:58:33

colorfusion
Scratcher
Registered: 2009-10-03
Posts: 500+

Re: Shield Lags Behind

You can also as the same movement script to the shield as ship.

Offline

 

#6 2010-09-24 17:37:48

tchan5158
New Scratcher
Registered: 2010-09-19
Posts: 25

Re: Shield Lags Behind

LOL you all are funny  smile

And thx ColorFusion.  I'll probably make the same movement for the shadow of the ship on a lower layer since I want it a bit offset.  Or just offset the center of the shadow sprite and use the broadcast command.  hmmm......   big_smile

Offline

 

#7 2010-09-24 17:50:58

cheddargirl
Scratch Team
Registered: 2008-09-15
Posts: 1000+

Re: Shield Lags Behind

Ay, let's not point out the bad word misspelling now, okay? ^^ *goes and fixes it*

I noticed that you used the ghost effect for the shield. Aside from the fact that there's a execution delay between blocks, costume effects (the ghost effect in this case) can also cause lag to some degree.  hmm

Making the movement script for the ship the same as the sprite should work, the broadcast technique could work as well in this case.  smile


http://i.imgur.com/8QRYx.png
Everything is better when you add a little cheddar, because when you have cheese your life is at ease  smile

Offline

 

#8 2010-09-24 18:32:49

roger-
Scratcher
Registered: 2010-02-13
Posts: 100+

Re: Shield Lags Behind

cheddargirl wrote:

Ay, let's not point out the bad word misspelling now, okay? ^^ *goes and fixes it*

I noticed that you used the ghost effect for the shield. Aside from the fact that there's a execution delay between blocks, costume effects (the ghost effect in this case) can also cause lag to some degree.  hmm

Making the movement script for the ship the same as the sprite should work, the broadcast technique could work as well in this case.  smile

It is not the lag between blocks that is the problem. it is the order of execution.
in your project, the sheild goes to the ship then the ship moves, thus resulting in a lagging shield. to fix this, just make the sheild go to the ship after the ship moves.


Food is Fat. Fat is power.
        I am almighty.

Offline

 

#9 2010-09-25 09:47:50

tchan5158
New Scratcher
Registered: 2010-09-19
Posts: 25

Re: Shield Lags Behind

roger- wrote:

It is not the lag between blocks that is the problem. it is the order of execution.  in your project, the sheild goes to the ship then the ship moves, thus resulting in a lagging shield. to fix this, just make the sheild go to the ship after the ship moves.

Oh I see... Thanks roger  big_smile

Before, I had the beginning of the shield like:
[blocks]
<when green flag clicked>
<forever>
<go to[ MainShip ]
[/blocks]

which is fine if the ship doesn't move, but once the ship moves, the shield has to catch up, thus resulting in "lag". 

But to fellow Scratchers' advice, I added a Broadcast so when any movement key is pressed, the shield goes with it, thus matching the movements perfectly. 

It was mentioned it can simple copy over the same movement controls as the ship to the shield.   big_smile

*gets smarter* o.o;

-Tommy

Offline

 

Board footer