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

#1 2012-11-14 07:01:27

Skyjaguar
New Scratcher
Registered: 2012-11-14
Posts: 4

Problem with Scratch- When sprites are in motion

When sprites are in motion and they are suppose to execute a command (for e.g. hide) if touching, the command is not executed unless they are nt in motion.


when gf clicked
glide <(1) secs to x:[240] y:[10]>
if <touching (sprite2)>
    hide

Offline

 

#2 2012-11-14 07:08:48

30-1
Scratcher
Registered: 2012-08-08
Posts: 100+

Re: Problem with Scratch- When sprites are in motion

That is because the script waits until the block has finished before executing the next block.

You could use this:

when gf clicked
forever
 point towards [sprite2 v]
 move (1) steps
 if <touching [sprite2 v]?>
  hide
 end
This topic should be moved to help with scripts.

Last edited by 30-1 (2012-11-14 07:10:34)


http://i.imgur.com/ocOya7x.gif
I. Text I Based I Games I

Offline

 

#3 2012-11-14 11:21:32

Skyjaguar
New Scratcher
Registered: 2012-11-14
Posts: 4

Re: Problem with Scratch- When sprites are in motion

When sprites are in motion and they are suppose to execute a command (for e.g. hide) if touching, the command is not executed unless they are nt in motion.

when gf clicked
glide (1) secs to x:(240) y:(150)<(timer) > [10]
if <touching [sprite2]?>
  hide

Offline

 

#4 2012-11-14 11:25:06

Skyjaguar
New Scratcher
Registered: 2012-11-14
Posts: 4

Re: Problem with Scratch- When sprites are in motion

It was helpful. Thanks Scratcher.

Offline

 

#5 2012-11-14 12:04:23

Skyjaguar
New Scratcher
Registered: 2012-11-14
Posts: 4

Re: Problem with Scratch- When sprites are in motion

It was helpful, but i am making a game where an aircraft at the bottom of the stage is firing missiles at object moving from the top of the stage towards the aircraft. When i use

when gf clicked
forever
  point towards [aircraft]
  Move (1) Steps
  if <touching [missile]>
    hide
it doesnt really work. Cuz i I wanted the objects to move gradually towards the aircraft and when the aircraft launches the missile, then the object hides.

Offline

 

#6 2012-11-14 12:13:25

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: Problem with Scratch- When sprites are in motion

broadcast [glide v] and wait //in the middle of a script
when i receive [glide v]// Both in same sprite
glide (1) secs to x:(whatever) y:(whatever)
set [done v] to [yes] //So it stops checking when you get to the position. Take out if you don't want that to happen.
when i receive [glide v]
set [done v] to [no]//Again, take out if you want it to keep checking when you get to the position
wait until <<touching [enemy v]?> or <(done) = [yes]>>
if <(done) = [no]>
  hide
end

Last edited by joefarebrother (2012-11-14 12:14:27)


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#7 2012-11-14 13:16:25

Llamalover
Scratcher
Registered: 2007-05-18
Posts: 100+

Re: Problem with Scratch- When sprites are in motion

I think this would be the simplest solution

when gf clicked
glide <(1) secs to x:[240] y:[10]>
end 
when gf clicked
forever
if <touching (sprite2)>
    hide
end 
end

Last edited by Llamalover (2012-11-14 13:16:53)


Be nice, I'm an old lady  wink

Offline

 

Board footer