r112/r113 Spawn new object does not select new obj

Bugs will be moved here once resolved.

Post » Thu Dec 20, 2012 10:34 pm

Hi!


Compare these two action sets:

a) Repeat 2 {
      System.Create object (Sprite1) at (Sprite2.X,Sprite2.Y)
      Sprite1.Set Bullet angle of motion to (floor(rnd*360))
}

b)Repeat 2 {
      Sprite2.spawn object (Sprite1) at point (0)
      Sprite1.Set Bullet angle of motion to (floor(rnd*360))
}

While (a) makes 2 different copies of Sprite1 moving at different angles, (b) shows two ovelapped instances of Sprite1 moving at same angle (user sees only one).

I guess "Sprite2.Spawn Sprite1" does not pick the new instance of Sprite1, while "System.Create Sprite1" does.

This behaviour should be clarified in manual and in the User Interface Hints.

(I've tested this with both r112 and r113).
B
39
S
11
G
5
Posts: 132
Reputation: 8,228

Post » Fri Dec 21, 2012 12:34 am

rnd is not an existing system expression.
The expression should be random(360) in your code.

If you created a global variable rnd, I suspect the value would be 0 in your second example, and the result would end up being 0.

See this example I just made in r113, all "Sprite2" instances have a random angle of motion meaning they got picked as expected.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Fri Dec 21, 2012 11:42 am

The only case it wouldn't pick the new object is if you have Sprite1: Spawn Sprite1.
B
54
S
28
G
18
Posts: 1,520
Reputation: 24,990

Post » Fri Dec 21, 2012 2:01 pm

Closing, please see how to report bugs and attach a .capx reproducing the problem if you believe this is a bug. It's impossible for us to reproduce your events because you have not defined what "rnd" is, and it may be critically related to the issue.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,518


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 1 guest