This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
en:guides:beginners:shooting_and_spawners [2021/07/15 15:10 (4 years ago)] – minor grammar and spelling corrections creampuff | en:guides:beginners:shooting_and_spawners [2024/11/18 05:08 (4 months ago)] (current) – Fix position and speed of the bullets sausage | ||
---|---|---|---|
Line 36: | Line 36: | ||
</ | </ | ||
- | Some words on the above. | + | This spawner can shoot '' |
Time to attach it to the '' | Time to attach it to the '' | ||
- | < | + | < |
[HeroObject] | [HeroObject] | ||
Graphic | Graphic | ||
- | Position | + | Position |
Scale = 2 | Scale = 2 | ||
AnimationSet = HeroAnimationSet | AnimationSet = HeroAnimationSet | ||
Line 72: | Line 72: | ||
Remove the spawner from the hero object, and make '' | Remove the spawner from the hero object, and make '' | ||
- | < | + | < |
[HeroObject] | [HeroObject] | ||
Graphic | Graphic | ||
Line 82: | Line 82: | ||
</ | </ | ||
- | When you run this, you'll notice little difference. Our hero is still firing. But now we can turn his gun off at the bottom of the Init() function. | + | When you run this, you'll notice little difference. Our hero is still firing. But now we can turn his gun off at the bottom of the '' |
But we need a reference to the gun in code, which we don't have yet because [HerosGun] was created automatically with HeroObject. | But we need a reference to the gun in code, which we don't have yet because [HerosGun] was created automatically with HeroObject. | ||
Line 88: | Line 88: | ||
First declare the gun as a variable just like the hero object: | First declare the gun as a variable just like the hero object: | ||
- | < | + | < |
orxOBJECT *hero; | orxOBJECT *hero; | ||
orxOBJECT *herosGun; | orxOBJECT *herosGun; | ||
</ | </ | ||
- | Then, in the Init() function, get the child reference of the gun using the hero object: | + | Then, in the '' |
- | < | + | < |
- | herosGun = (orxOBJECT*)orxObject_GetChild(hero); | + | hero = orxObject_CreateFromConfig(" |
+ | | ||
+ | orxObject_CreateFromConfig(" | ||
</ | </ | ||
Now that you have the reference, turn off the '' | Now that you have the reference, turn off the '' | ||
- | < | + | < |
- | orxObject_Enable(herosGun, | + | hero = orxObject_CreateFromConfig(" |
+ | herosGun = (orxOBJECT*)orxObject_GetChild(hero); | ||
+ | | ||
+ | orxObject_CreateFromConfig(" | ||
</ | </ | ||
Compile and run. | Compile and run. | ||
- | Cool, he stopped shooting. The last thing, turn on, and off the shooting based on pressing the left control key: | + | Cool, he stopped shooting. The last thing, turn on, and off the shooting based on pressing the left control key in the '' |
< | < | ||
Line 122: | Line 127: | ||
Hmmm... His bullets don't go left when the hero faces left. Change the spawner by adding '' | Hmmm... His bullets don't go left when the hero faces left. Change the spawner by adding '' | ||
- | < | + | < |
[BulletSpawner] | [BulletSpawner] | ||
Object | Object | ||
WaveSize | WaveSize | ||
WaveDelay | WaveDelay | ||
- | Position | + | Position |
- | ObjectSpeed | + | ObjectSpeed |
UseRelativeSpeed = true | UseRelativeSpeed = true | ||
</ | </ |