Hi,
I'm creating a new library and I want to move a programmatically added imageview x pixels to the left.
Now i'm receiving a RuntimeException at MoveLeft:
The view should be initialized with ImageViewWrapper imgObject = new ImageViewWrapper();
imgObject.Initialize(ba, "imgObject"); and the id log gives me id: 2.
DrawingPanel is a Panel from B4A.
Any help?
Kind regards,
Tomas
I'm creating a new library and I want to move a programmatically added imageview x pixels to the left.
B4X:
ImageViewWrapper imgObject = new ImageViewWrapper();
imgObject.Initialize(ba, "imgObject");
imgObject.setBitmap(GameObject.getBitmap());
Log.i("B4A","GameFramework: " + imgObject.getObject().getId());
GameObject.setXPosition(x);
GameObject.setYPosition(y);
this.DrawingPanel.AddView(imgObject.getObject(), x, y, GameObject.getBitmap().getHeight(), GameObject.getBitmap().getHeight());
GameObject.setID(imgObject.getObject().getId());
B4X:
/**
* Gets or sets the ID of this game object.
* WARNING! Not recommended to change the id!
* An id will be given when the object is placed on the drawing panel.
*/
public int getID() {
return this.id;
}
/**
* Gets or sets the ID of this game object.
* WARNING! Not recommended to change the id!
* An id will be given when the object is placed on the drawing panel.
*/
public void setID(int id) {
this.id = id;
}
B4X:
/**
* Moves the Game Object to the left.
* X - the amount of pixels to go left
*/
public void MoveLeft(int x) {
this.GameObject.setXPosition(this.GameObject.getXPosition()-x);
this.GameEngine.getDrawingPanel().GetView(GameObject.getID()).setLeft(GameObject.getXPosition()-x);
}
Now i'm receiving a RuntimeException at MoveLeft:
Object should first be initialized.
The view should be initialized with ImageViewWrapper imgObject = new ImageViewWrapper();
imgObject.Initialize(ba, "imgObject"); and the id log gives me id: 2.
DrawingPanel is a Panel from B4A.
Any help?
Kind regards,
Tomas
Last edited: