Show specific sprites on specific cameras?

134 views
Skip to first unread message

Mixer

unread,
Jun 25, 2015, 6:56:33 AM6/25/15
to haxef...@googlegroups.com
Hi. In one of the camera demos, it says that you are able to control which sprites are drawn on which cameras, however I have found nothing about this in the haxeflixel documentation. Is someone able to point me in the right direction for only showing certain sprites on certain cameras? Thanks :)

Thom Sip

unread,
Jun 25, 2015, 7:49:57 AM6/25/15
to haxef...@googlegroups.com
Old post about the original Flixel, but I believe it still works pretty much the same.

http://videlais.com/2013/11/06/flixel-use-multiple-cameras-for-a-heads-up-display-as3/

Bassicaly if you set the camera(s) of a flxGroup (or FlxSprite) manually. Only those cameras will render the sprite(s). By default all flxSprites are rendered on every camera.

Not tested and also not sure about this. Anybody please correct me if I'm wrong

SruloArt

unread,
Jun 25, 2015, 8:07:23 AM6/25/15
to haxef...@googlegroups.com
It's a little bit different than the link though:

1. Create a new camera:
 var happyCam = new FlxCamera(50, 50, 300, 300, 0);

2. Add it to the game's cameras:
FlxG.cameras.add(happyCam);

3. Change the camera your sprite is using:
sprite.camera = happyCam;

It can be a lot more complex than that (multiple cameras and so on), but this is the basic concept.

Mixer

unread,
Jun 26, 2015, 3:52:31 AM6/26/15
to haxef...@googlegroups.com
Thanks for your reply guys. I followed the link and was successful at hiding a group, although .camera on a sprite wasn't there. Hiding a group works fine though, so I might just use that. Strange you can't set it per sprite though, but this will do.

Gama11

unread,
Jun 26, 2015, 8:39:25 AM6/26/15
to haxef...@googlegroups.com, danth...@live.com.au
What do you mean, it "wasn't there"? FlxObject has a camera property.
Reply all
Reply to author
Forward
0 new messages