import com.badlogic.gdx.*;
import com.badlogic.gdx.graphics.*;
import com.badlogic.gdx.graphics.g2d.*;
import com.badlogic.gdx.scenes.scene2d.*;
import com.badlogic.gdx.scenes.scene2d.utils.*;
import com.badlogic.gdx.scenes.scene2d.ui.*;
import com.badlogic.gdx.utils.viewport.*;
import com.badlogic.gdx.audio.*;

public class MyGdxGame implements ApplicationListener{
Music m;
private Stage stage,stage2;
    private Texture myTexture,tex2;
    private TextureRegion myTextureRegion,reg2;
    private TextureRegionDrawable myTexRegionDrawable,draw2;
    private ImageButton button,button2;

    @Override
    public void create(){  
m =Gdx.audio.newMusic(Gdx.files.internal("ms.mp3"));
tombol1();
tombol2();
    Gdx.input.setInputProcessor(new InputMultiplexer(stage,stage2));}
   
@Override
    public void render(){
renderTombol1();
renderTombol2();}

///////////////////TOMBOL SATU////////////////////////////////
public void tombol1(){
myTexture = new Texture(Gdx.files.internal("android.jpg"));
        myTextureRegion = new TextureRegion(myTexture,0,0,100,100);
        myTexRegionDrawable = new TextureRegionDrawable(myTextureRegion);
        button = new ImageButton(myTexRegionDrawable); //Set the button up
        stage = new Stage(new ScreenViewport()); //Set up a stage for the ui
stage.addActor(button); }
public void renderTombol1(){
stage2.act(Gdx.graphics.getDeltaTime()); //Perform ui logic
        stage2.draw(); //Draw the ui
button2.addListener(new EventListener(){
@Override
public boolean handle(Event event){
m.stop();
return false;}});}
////////////////////TOMBOL DUA///////////////////////////////////////
public void tombol2(){
tex2 = new Texture(Gdx.files.internal("android.jpg"));
        reg2= new TextureRegion(tex2,50,0,100,100);
        draw2 = new TextureRegionDrawable(reg2);
        button2 = new ImageButton(draw2); //Set the button up
        button2.setPosition(300,0);
stage2 = new Stage(new ScreenViewport()); //Set up a stage for the ui
        stage2.addActor(button2); }
public void renderTombol2(){
stage.act(Gdx.graphics.getDeltaTime()); //Perform ui logic
stage.draw(); //Draw the ui
button.addListener(new EventListener(){
@Override
public boolean handle(Event even)
    {m.play(); return false;}});
}
//////////////////////////////////////////////////////////////////////
@Override
public void resize(int p1, int p2){}
@Override
public void pause(){}
@Override
public void resume(){}
@Override
public void dispose(){}
}

[LIBGDX] ImageButton Multi Stage

Posted by : Unknown 0 Comments

import com.badlogic.gdx.*;
import com.badlogic.gdx.graphics.*;
import com.badlogic.gdx.graphics.g2d.*;
import com.badlogic.gdx.math.*;

public class MyGdxGame implements ApplicationListener{ TextureRegion objectA;
TextureRegion obj1;
TextureRegion obj2;
SpriteBatch batch;
BitmapFont font;
Vector2 velocityObj1;
Rectangle RegObj1;
Rectangle RegObj2;
Boolean hidup=true;
float time;

@Override
public void create(){
Texture object1=new Texture(Gdx.files.internal("obj1.png"));
Texture object2=new Texture(Gdx.files.internal("obj2.png"));
obj1=new TextureRegion(object1,0,0,100,100);
obj2=new TextureRegion(object2,0,0,100,100);
RegObj1 =new Rectangle();
RegObj1.width=object1.getWidth();
RegObj1.height=object1.getHeight();
RegObj1.x=0;
RegObj1.y=0;
RegObj2=new Rectangle();
RegObj2.width=object2.getWidth();
RegObj2.height=object2.getHeight();
RegObj2.x=300;
RegObj2.y=0;
velocityObj1=new Vector2(10,0);
batch=new SpriteBatch();
font=new BitmapFont();
font.setColor(Color.RED);
font.setScale(2);
hidup=false;
}

@Override
public void render(){
Gdx.gl.glClearColor(1,1,1,1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT|GL20.GL_DEPTH_BUFFER_BIT);
batch.begin();
batch.draw(obj1,RegObj1.x,0,100,100);
batch.draw(obj2,RegObj2.x,0,100,100);
RegObj2.x=350;
if(hidup){
font.draw(batch,"Collision Detected",100,500);
}
batch.end();
time+=Gdx.graphics.getDeltaTime();
RegObj1.x=velocityObj1.x-=0*Gdx.graphics.getDeltaTime();
if(Gdx.input.isTouched()){
velocityObj1.x+=500*Gdx.graphics.getDeltaTime();
}
if(RegObj1.overlaps(RegObj2)){
hidup=true;
}
}

@Override
public void resize(int width, int height){
}

@Override
public void pause(){
}

@Override
public void resume(){
}

@Override
public void dispose()
{
batch.dispose();
font.dispose();
}

}

[LIBGDX] Collision Detection

Posted by : Unknown 0 Comments

Layar 1

import com.badlogic.gdx.*;
import com.badlogic.gdx.graphics.*;
import com.badlogic.gdx.graphics.g2d.*;
public class MyGdxGame extends Game{
SpriteBatch batch;
BitmapFont font;

@Override
public void create(){
batch = new SpriteBatch();   
font = new BitmapFont();
font.setColor(Color.RED);
font.setScale(2);}

@Override
public void render(){       
//warna background
Gdx.gl.glClearColor(1, 1, 1, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
//tata letak text ganti X dan Y dengan angka
font.draw(batch, "tap dimana saja untuk pindah layar", 0, 400);
batch.end();
if(Gdx.input.isTouched()){
this.setScreen(new MainMenuScreen(this));}
super.render();}

@Override
public void dispose(){
batch.dispose();
font.dispose();}
   
@Override
public void resize(int width, int height){}
@Override
public void pause(){}
@Override
public void resume(){}
}

Layar 2

import com.badlogic.gdx.*;
import com.badlogic.gdx.graphics.*;
import com.badlogic.gdx.graphics.g2d.*;
import javax.microedition.khronos.opengles.*;
public class MainMenuScreen implements Screen{
final MyGdxGame game;
SpriteBatch batch;
Texture image;
TextureRegion imageRegion;
OrthographicCamera camera;
public MainMenuScreen(final MyGdxGame game){
this.game = game;}

@Override
public void show(){
camera = new OrthographicCamera();
camera.setToOrtho(false, 800, 480);
image=new Texture(Gdx.files.internal("android.jpg"));
imageRegion=new TextureRegion(image,0,0,1000,1000);
batch=new SpriteBatch();}

@Override
public void render(float p1){
Gdx.gl.glClearColor(1, 1, 1, 1);
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
batch.begin();
batch.draw(imageRegion,0,0,200, 200);
batch.end();}

@Override
public void resize(int p1, int p2){}
@Override
public void hide(){}
@Override
public void pause(){}
@Override
public void resume(){}
@Override
public void dispose(){}
}

[LIBGDX] SplashScreen

Posted by : Unknown 0 Comments

//tanpa controller

VideoView simpleVideoView = (VideoView) findViewById(R.id.vd); // initiate a video view
simpleVideoView.setVideoURI(Uri.parse("android.resource://" + this.getPackageName() + "/" + R.raw.v));
simpleVideoView.start();

[Droid] VideoView tanpa Controller

Posted by : Unknown 0 Comments
Tag : ,

Use the permission Internet

MainActivity.java
import android.os.Bundle;
import android.app.*;
import com.google.android.gms.ads.AdRequest; //Import class AdRequest
import com.google.android.gms.ads.AdView;    //import class Adview

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        AdView mAdView = (AdView) findViewById(R.id.adView);
        AdRequest adRequest = new AdRequest.Builder().build();
        mAdView.loadAd(adRequest);
    }
}

Main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
    <TextView android:text="@string/app_name" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
    <!--menambahkan elemen AdView untuk menampilkan iklan/ads-->
    <com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_ad_unit_id">
    </com.google.android.gms.ads.AdView>
</RelativeLayout>

String.xml

<string name="banner_ad_unit_id">ca-app-pub-3940256099942544/6300978111</string>

[DROID] Admob Banner

Posted by : Unknown 0 Comments

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body bgcolor="white">
<h1>Melki Mitsuki</h1><br>
<div id="tambah">tambah
</div>
<div id="remove">remove
</div>
<script>
$(document).ready(function(){
$('#tambah').click(function(){

$('#tambah').append('<div>tambah element berada di dalam dan di bagian bawah ganti append dengan prepend (untuk element berada di atas) after (eleement berada di bagian bawah tapi di luar) before (element berada di atas tapi diluar) remove (untuk menghapus elemen menurut id) empty (menghapus isi dari sebuah element menurut id)</div>');

});
$('#remove').click(function(){
$('#tambah').remove();
});

});
</script>
</body>
</html>

[JQUERY] menulis dan menghapus element

Posted by : Unknown 0 Comments

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body bgcolor="white">
<h1>Melki Mitsuki</h1><br>
<form>
<input type="text" id="t"/>
<input type="submit" value="klik"/>
</form>
<script>
$(document).ready(function(){
$('form').submit(function(){
var isi=($('#t').val());
$('h1').text(isi);
event.preventDefault();
});

});
</script>
</body>
</html>

[JQUERY] Get & Set

Posted by : Unknown 0 Comments

- Copyright © BLOG GUE WANGI - Blogger Templates - Powered by Blogger - Designed by Johanes Djogan -