/**the main build method , we build the mesh and the texture and also the physical object */ public final void build(){ texture = Engine.resource(data.texture,Texture.class); if(null!=this.texture){ this.texture.setWrap(TextureWrap.Repeat, TextureWrap.Repeat); this.texture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); } if(data.points.size>2 && this.texture !=null)this.doBuild(); } /** to draw it */
@Override public void onResourcesRegister(AliasResourceManager<String> reg) { reg.texture("S1", "data/laser/start1.png"); reg.texture("S2", "data/laser/start2.png"); reg.texture("M1", "data/laser/mid1.png"); reg.texture("M2", "data/laser/mid2.png"); reg.texture("E1", "data/laser/end1.png"); reg.texture("E2", "data/laser/end2.png"); reg.object("Begin1", new Sprite(Engine.resource("S1", Texture.class))); reg.object("Begin2", new Sprite(Engine.resource("S2", Texture.class))); reg.object("Mid1", new Sprite(Engine.resource("M1", Texture.class))); reg.object("Mid2", new Sprite(Engine.resource("M2", Texture.class))); reg.object("End1", new Sprite(Engine.resource("E1", Texture.class))); reg.object("End2", new Sprite(Engine.resource("E2", Texture.class))); }
public void stopMusic(String res){ final Music musicFromPool = musics.get(res); if(null==musicFromPool){ final Music musicFromAssets = Engine.resource(res); musics.put(res, musicFromAssets); musicFromAssets.stop(); }else{ musicFromPool.stop(); } }
public void playMusic(String res,boolean loop){ final Music musicFromPool = musics.get(res); if(null==musicFromPool){ final Music musicFromAssets =Engine.resource(res); musics.put(res, musicFromAssets); this.playMusic(musicFromAssets,loop); }else{ this.playMusic(musicFromPool,loop); } }
public long playSound(final String res,final float soundVolume){ final Sound soundFromPool = this.sounds.get(res); if(null==soundFromPool){ final Sound soundFromAssets = Engine.resource(res); if(null!=soundFromAssets){ this.sounds.put(res, soundFromAssets); return this.playSound(soundFromAssets, soundVolume); } }else{ return this.playSound(soundFromPool, soundVolume); } return -1; } private long playSound(final Sound sound,final float soundVolume){
public SceneHelper(final MainScene adapter) { super(adapter); TextureAtlas atlas = Engine.resource("TA"); bodyMode = new LeftTopImage(atlas.findRegion("bodyMode")); jointModel = new LeftTopImage(atlas.findRegion("jointMode")); this.addActor(bodyMode); }
private SceneA() { sprite = new AdvanceSprite(Engine.resource("A", Texture.class)); sprite.setSize(Engine.getWidth(), Engine.getHeight()); sprite.setColor(Color.RED); }
private SceneB() { sprite = new AdvanceSprite(Engine.resource("A", Texture.class)); sprite.setSize(Engine.getWidth(), Engine.getHeight()); sprite.setColor(Color.YELLOW); }
@Override public void onResourcesRegister(AliasResourceManager<String> reg) { reg.texture("logo", "data/c2d.png"); reg.texture("ControlBase", "data/analog/control-base.png"); reg.texture("ControlKnob", "data/analog/control-knob.png"); reg.object("logoSprite", new AdvanceSprite(Engine.resource("logo", Texture.class))); }
public MainScene() { actor = new AdvanceSpriteImage(new AnimationSprite(0.05f, Engine.resource("Anim", TextureAtlas.class), "fly")); actor.setPosition(200, 100); this.addActor(actor); this.shake(); }
public void pauseMusic(String res){ final Music musicFromPool = musics.get(res); if(null==musicFromPool){ final Music musicFromAssets = Engine.resource(res); musics.put(res, musicFromAssets); if(musicFromAssets.isPlaying()){ musicFromAssets.pause(); } }else{ if(musicFromPool.isPlaying()){ musicFromPool.pause(); } } } public void playMusic(String res,boolean loop){
@Override public void render(float delta) { Engine.getSpriteBatch().begin(); Engine.getSpriteBatch().draw(Engine.resource("AAA", Texture.class), 100, 100); Engine.getSpriteBatch().end(); Engine.debugInfo("touch the screen to get a in game loading"); }
@Override public void render(float delta) { Engine.getSpriteBatch().begin(); Engine.getSpriteBatch().draw(Engine.resource("logo", Texture.class), 0, 0); Engine.getSpriteBatch().end(); Engine.debugInfo("This will load all resources and just play a sound and a music"); }
public MainScene() { actor = new AdvanceSpriteImage(new AnimationSprite(0.05f, Engine.resource("Anim", TextureAtlas.class), "fly")); actor.setPosition(200, 100); actor.addAction(Actions.forever( Actions.sequence( Actions.alpha(0.1f, 0.1f), Actions.fadeIn(0.1f) ) )); this.addActor(actor); }
public MainScene() { actor = new AdvanceSpriteImage(new AnimationSprite(0.05f, Engine.resource("Anim", TextureAtlas.class), "fly")); actor.setPosition(200, 100); actor.addAction(Actions.forever( Actions.sequence( Actions.color(new Color(Color.BLUE), 1), Actions.color(new Color(Color.YELLOW), 1) ) )); this.addActor(actor); }
public MainScene() { actor = new AdvanceSpriteImage(new AnimationSprite(0.05f, Engine.resource("Anim", TextureAtlas.class), "fly")); actor.setPosition(200, 100); actor.addAction(Actions.forever( Actions.sequence( Actions.scaleTo(3, 1, 1), Actions.scaleTo(1, 1, 1), Actions.scaleTo(1, 3, 1), Actions.scaleTo(3, 1, 1) ) )); this.addActor(actor); }
void addNewHandle(Table table, String region, String txt, ClickListener l) { TextureAtlas atlas = Engine.resource("TA"); DefaultLabel label = DefaultLabel.getDefaultLabel(txt + " "); label.addListener(l); table.add(new Image(new TextureRegionDrawable(atlas.findRegion(region)), Scaling.none)).height(30).spaceRight(10); table.add(label).right().spaceRight(10); table.row(); } }
public MainScene() { actor = new AdvanceSpriteImage(new AnimationSprite(0.05f, Engine.resource("Anim", TextureAtlas.class), "fly")); actor.setPosition(200, 100); actor.addAction(Actions.forever( Actions.sequence( Actions.moveTo(300, 100, 1, Interpolation.bounceOut), Actions.moveBy(200, 0, 1, Interpolation.bounceOut), Actions.moveBy(0, 250, 1), Actions.moveTo(200, 350, 1, Interpolation.swingOut), Actions.moveTo(200, 100, 1, Interpolation.swingOut) ) )); this.addActor(actor); }
public void show(boolean isBoss, String text) { this.clear(); if (isBoss) { String[] strs = text.split(""); float width = 0; for (int i = 0; i < strs.length; i++) { String s = strs[i]; Label temp = new Label(s, new LabelStyle(Engine.resource("Font", BitmapFont.class), Color.WHITE)); temp.setPosition(width, 400); temp.addAction(Actions.delay(0.1f * i, Actions.sequence(Actions.moveBy(0, -300, 0.5f, Interpolation.swingOut), Actions.delay(1f, Actions.moveBy(0, 300, 0.3f))))); this.addActor(temp); width += temp.getPrefWidth(); } this.setPosition(Engine.getWidth() / 2 - width / 2, 100); } else { Label battleLabel = new Label(text, new LabelStyle(Engine.resource("Font", BitmapFont.class), Color.WHITE)); this.setSize(battleLabel.getPrefWidth(), battleLabel.getPrefHeight()); this.setPosition(Engine.getWidth() / 2 - battleLabel.getPrefWidth() / 2, 200); this.setOrigin(this.getWidth() / 2, this.getHeight() / 2); this.setScale(0); this.addAction(sequence(scaleTo(1, 1, 1f, Interpolation.swingOut), delay(1f), Actions.moveBy(50, 0, 0.1f), Actions.moveBy(-1500, 0, 0.3f))); this.addActor(battleLabel); } } }
@Override public void onLoadedResourcesCompleted() { final TextureAtlas bgAtlas = Engine.resource("bgAtlas", TextureAtlas.class); rbg = new ParallaxGroup(480, 320, new Vector2(50, 100)); rbg.addActor(new Image(new AdvanceSprite(bgAtlas.findRegion("bg")))); rbg.addActor(new ParallaxLayer(rbg, new Image(new AdvanceSprite(bgAtlas.findRegion("cloud"))), new Vector2(0.5f, 0), new Vector2(0, 1000), new Vector2(0, 70))); rbg.addActor(new ParallaxLayer(rbg, new Image(new AdvanceSprite(bgAtlas.findRegion("front"))), new Vector2(1f, 0), new Vector2(0, 1000), new Vector2())); rbg.addActor(new ParallaxLayer(rbg, new Image(new AdvanceSprite(bgAtlas.findRegion("dock-tree"))), new Vector2(1f, 0), new Vector2(1000, 1000), new Vector2())); rbg.addAction(Actions.forever(Actions.sequence( ParallaxGroupSpeedToAction.obtain(1000, 300, 1), ParallaxGroupSpeedToAction.obtain(50, 300, 2), Actions.scaleTo(2, 2, 0.5f), Actions.scaleTo(1, 1, 1.5f) ))); final SceneStage stage = new SceneStage(); final Group group = new Group(); group.setScale(Engine.getWidth() / 480f); group.addActor(rbg); stage.addActor(group); Engine.setMainScene(stage); } }