How do I store an object as variable in another object?

Get help using Construct 2

Post » Mon Jul 06, 2015 8:06 am

Say I have three object types.
Player, weapon, bullet.

Then I want to have a variable in player for the currently used weapon, and a variable in weapon for the bullet type it uses.

example

player.weapon = lasergun
lasergun.bullet = laserbullet

if left click
player spawn player.weapon.bullet


How should i program these kinds of situations as simple as possible?
B
7
Posts: 10
Reputation: 297

Post » Mon Jul 06, 2015 8:41 am

It is unclear how many players/weapons do you have on screen in any given time.

But you can use different sprites for different weapons. And one variable for bullet type.

And then check

On click-->
If Weapon1 is on screen -->
if bullet = 1 --> create bullet1 at weapon1.x/weapon1.y
if bullet = 2 --> create bullet2 at weapon1.x/weapon1.y
B
7
S
2
Posts: 68
Reputation: 645

Post » Mon Jul 06, 2015 8:47 am

B
108
S
26
G
272
Posts: 4,471
Reputation: 152,277


Return to How do I....?

Who is online

Users browsing this forum: asdtricky, pmerineau, Yarfapet and 13 guests